![]() |
MySQL 8.0.43
Source Code Documentation
|
Class which manages slow and general log event handlers. More...
#include <log.h>
Public Member Functions | |
| Query_logger () | |
| bool | is_log_table_enabled (enum_log_table_type log_type) const |
| Check if table logging is turned on for the given log_type. More... | |
| bool | is_log_file_enabled (enum_log_table_type log_type) const |
| Check if file logging is turned on for the given log type. More... | |
| void | init () |
| Perform basic log initialization: create file-based log handler. More... | |
| void | cleanup () |
| Free memory. More... | |
| bool | slow_log_write (THD *thd, const char *query, size_t query_length, bool aggregate, ulonglong lock_usec, ulonglong exec_usec) |
| Log slow query with all enabled log event handlers. More... | |
| bool | general_log_print (THD *thd, enum_server_command command, const char *format,...) |
| Write printf style message to general query log. More... | |
| bool | general_log_write (THD *thd, enum_server_command command, const char *query, size_t query_length) |
| Write query to general query log. More... | |
| void | set_handlers (ulonglong log_printer) |
| Enable log event handlers for slow/general log. More... | |
| bool | activate_log_handler (THD *thd, enum_log_table_type log_type) |
| Activate log handlers for the given log type. More... | |
| void | deactivate_log_handler (enum_log_table_type log_type) |
| Close file log for the given log type. More... | |
| bool | reopen_log_file (enum_log_table_type log_type) |
| Close file log for the given log type and the reopen it. More... | |
| bool | set_log_file (enum_log_table_type log_type) |
| Read log file name from global variable opt_*_logname. More... | |
| enum_log_table_type | check_if_log_table (Table_ref *table_list, bool check_if_opened) const |
| Check if given Table_ref has a query log table name and optionally check if the query log is currently enabled. More... | |
Private Member Functions | |
| void | init_query_log (enum_log_table_type log_type, ulonglong log_printer) |
| Setup log event handlers for the given log_type. More... | |
Private Attributes | |
| mysql_rwlock_t | LOCK_logger |
| RW-lock protecting Query_logger. More... | |
| Log_to_csv_event_handler | table_log_handler |
| Available log handlers. More... | |
| Log_to_file_event_handler * | file_log_handler |
| Log_event_handler * | slow_log_handler_list [MAX_LOG_HANDLERS_NUM+1] |
| NULL-terminated arrays of log handlers. More... | |
| Log_event_handler * | general_log_handler_list [MAX_LOG_HANDLERS_NUM+1] |
Static Private Attributes | |
| static const uint | MAX_LOG_HANDLERS_NUM = 2 |
| Currently we have only 2 kinds of logging functions: old-fashioned file logs and csv logging routines. More... | |
Class which manages slow and general log event handlers.
|
inline |
| bool Query_logger::activate_log_handler | ( | THD * | thd, |
| enum_log_table_type | log_type | ||
| ) |
Activate log handlers for the given log type.
| thd | Thread handle |
| log_type | QUERY_LOG_SLOW or QUERY_LOG_GENERAL |
| enum_log_table_type Query_logger::check_if_log_table | ( | Table_ref * | table_list, |
| bool | check_if_opened | ||
| ) | const |
Check if given Table_ref has a query log table name and optionally check if the query log is currently enabled.
| table_list | Table_ref representing the table to check |
| check_if_opened | Always return QUERY_LOG_NONE unless the query log table is enabled. |
| QUERY_LOG_NONE,QUERY_LOG_SLOW | or QUERY_LOG_GENERAL |
| void Query_logger::cleanup | ( | ) |
Free memory.
Nothing could be logged after this function is called.
| void Query_logger::deactivate_log_handler | ( | enum_log_table_type | log_type | ) |
Close file log for the given log type.
| log_type | QUERY_LOG_SLOW or QUERY_LOG_GENERAL |
| bool Query_logger::general_log_print | ( | THD * | thd, |
| enum_server_command | command, | ||
| const char * | format, | ||
| ... | |||
| ) |
Write printf style message to general query log.
| thd | THD of the statement being logged. |
| command | COM of statement being logged. |
| format | Printf style format of message. |
| ... | Printf parameters to write. |
| bool Query_logger::general_log_write | ( | THD * | thd, |
| enum_server_command | command, | ||
| const char * | query, | ||
| size_t | query_length | ||
| ) |
Write query to general query log.
| thd | THD of the statement being logged. |
| command | COM of statement being logged. |
| query | The query string being logged. |
| query_length | The length of the query string. |
| void Query_logger::init | ( | ) |
Perform basic log initialization: create file-based log handler.
We want to initialize all log mutexes as soon as possible, but we cannot do it in constructor, as safe_mutex relies on initialization, performed by MY_INIT(). This why this is done in this function.
|
private |
Setup log event handlers for the given log_type.
| log_type | QUERY_LOG_SLOW or QUERY_LOG_GENERAL |
| log_printer | Bitmap of LOG_NONE, LOG_FILE, LOG_TABLE |
| bool Query_logger::is_log_file_enabled | ( | enum_log_table_type | log_type | ) | const |
Check if file logging is turned on for the given log type.
| log_type | QUERY_LOG_SLOW or QUERY_LOG_GENERAL |
| bool Query_logger::is_log_table_enabled | ( | enum_log_table_type | log_type | ) | const |
Check if table logging is turned on for the given log_type.
| log_type | QUERY_LOG_SLOW or QUERY_LOG_GENERAL |
| bool Query_logger::reopen_log_file | ( | enum_log_table_type | log_type | ) |
Close file log for the given log type and the reopen it.
| log_type | QUERY_LOG_SLOW or QUERY_LOG_GENERAL |
| void Query_logger::set_handlers | ( | ulonglong | log_printer | ) |
Enable log event handlers for slow/general log.
| log_printer | Bitmask of log event handlers. |
| bool Query_logger::set_log_file | ( | enum_log_table_type | log_type | ) |
Read log file name from global variable opt_*_logname.
If called from a sys_var update function, the caller must hold a lock protecting the sys_var (LOCK_global_system_variables, a polylock for the variable, etc.).
| log_type | QUERY_LOG_SLOW or QUERY_LOG_GENERAL |
| bool Query_logger::slow_log_write | ( | THD * | thd, |
| const char * | query, | ||
| size_t | query_length, | ||
| bool | aggregate, | ||
| ulonglong | lock_usec, | ||
| ulonglong | exec_usec | ||
| ) |
Log slow query with all enabled log event handlers.
| thd | THD of the statement being logged. |
| query | The query string being logged. |
| query_length | The length of the query string. |
| aggregate | True if writing log throttle record |
| lock_usec | Lock time, in microseconds. Only used when aggregate is true. |
| exec_usec | Execution time, in microseconds. Only used when aggregate is true. |
|
private |
|
private |
|
private |
RW-lock protecting Query_logger.
R-lock taken when writing to slow/general query log. W-lock taken when activating/deactivating logs.
|
staticprivate |
Currently we have only 2 kinds of logging functions: old-fashioned file logs and csv logging routines.
|
private |
NULL-terminated arrays of log handlers.
|
private |
Available log handlers.