MySQL 8.0.39
Source Code Documentation
|
Classes | |
class | FileHandler |
Handler that writes to a file. More... | |
class | Handler |
Base class for log message handler. More... | |
class | Logger |
Logger class. More... | |
class | NullHandler |
Handler to write to a null device such as /dev/null (unix) or NUL (windows). More... | |
struct | Record |
Log record containing information collected by the logging system. More... | |
class | Registry |
class | StreamHandler |
Handler to write to an output stream. More... | |
Enumerations | |
enum class | LogLevel { kFatal , kSystem , kError , kWarning , kInfo , kNote , kDebug , kNotSet } |
Log level values. More... | |
enum class | LogTimestampPrecision { kSec = 0 , kMilliSec = 3 , kMicroSec = 6 , kNanoSec = 9 , kNotSet } |
Log timestamp precision values. More... | |
Functions | |
HARNESS_EXPORT bool | log_level_is_handled (LogLevel level, const char *domain) |
static bool | log_level_is_handled (LogLevel level) |
HARNESS_EXPORT LogLevel | log_level_from_string (std::string name) |
Converts string with log level description to LogLevel type. More... | |
HARNESS_EXPORT LogLevel | get_default_log_level (const Config &config, bool raw_mode=false) |
Get default log level. More... | |
HARNESS_EXPORT std::string | get_default_log_filename (const Config &config) |
Get default log filename. More... | |
HARNESS_EXPORT void | attach_handler_to_all_loggers (Registry ®istry, std::string name) |
Attach handler to all loggers. More... | |
HARNESS_EXPORT void | set_log_level_for_all_loggers (Registry ®istry, LogLevel level) |
Set log levels for all the loggers to specified value. More... | |
HARNESS_EXPORT void | set_log_level_for_all_handlers (const Registry ®istry, LogLevel level) |
Set log levels for all handlers to specified value. More... | |
HARNESS_EXPORT LogTimestampPrecision | log_timestamp_precision_from_string (std::string name) |
Converts string with log timestamp precision description to LogTimestampPrecision type. More... | |
HARNESS_EXPORT LogTimestampPrecision | get_default_timestamp_precision (const Config &config) |
Get default timestamp precision. More... | |
HARNESS_EXPORT void | set_timestamp_precision_for_all_loggers (Registry ®istry, LogTimestampPrecision precision) |
Set timestamp precision for all the loggers. More... | |
HARNESS_EXPORT void | clear_registry (Registry ®istry) |
Clear registry. More... | |
HARNESS_EXPORT void | create_module_loggers (Registry ®istry, const LogLevel level, const std::list< std::string > &modules, const std::string &main_app_log_domain) |
Initialize logging facility. More... | |
HARNESS_EXPORT void | create_logger (Registry ®istry, const LogLevel level, const std::string &logger_name) |
HARNESS_EXPORT void | create_main_log_handler (Registry ®istry, const std::string &program, const std::string &logging_folder, bool format_messages, bool use_os_log=false) |
Initialize logfile handler. More... | |
HARNESS_EXPORT void | set_log_level_for_all_loggers (LogLevel level) |
Set log level for all registered loggers. More... | |
HARNESS_EXPORT void | set_log_level_for_all_handlers (LogLevel level) |
Set log level for all registered handlers. More... | |
HARNESS_EXPORT void | set_timestamp_precison_for_all_loggers (LogTimestampPrecision precision) |
Set timestamp precision for all registered loggers. More... | |
HARNESS_EXPORT void | register_handler (std::string name, std::shared_ptr< Handler > handler) |
Register handler for all plugins. More... | |
HARNESS_EXPORT void | unregister_handler (std::string name) |
Unregister a handler. More... | |
HARNESS_EXPORT std::ostream * | get_default_logger_stream () |
Returns pointer to the default logger sink stream. More... | |
void | set_timestamp_precision_for_all_loggers (LogTimestampPrecision precision) |
static void | log_system (const char *fmt,...) ATTRIBUTE_GCC_FORMAT(printf |
static void static void | log_error (const char *fmt,...) ATTRIBUTE_GCC_FORMAT(printf |
static void static void static void | log_warning (const char *fmt,...) ATTRIBUTE_GCC_FORMAT(printf |
static void static void static void static void | log_info (const char *fmt,...) ATTRIBUTE_GCC_FORMAT(printf |
static void static void static void static void static void | log_note (const char *fmt,...) ATTRIBUTE_GCC_FORMAT(printf |
static void static void static void static void static void static void | log_debug (const char *fmt,...) ATTRIBUTE_GCC_FORMAT(printf |
static void static void static void static void static void static void static void | log_custom (const LogLevel log_level, const char *fmt,...) ATTRIBUTE_GCC_FORMAT(printf |
Variables | |
const size_t | kLogMessageMaxSize = 4096 |
Max message length that can be logged; if message is longer, it will be truncated to this length. More... | |
constexpr char | kConfigOptionLogFilename [] = "filename" |
Section name and option name used in config file (and later in configuration object) to specify log level, best explained by example: More... | |
constexpr char | kConfigOptionLogDestination [] = "destination" |
constexpr char | kConfigOptionLogLevel [] = "level" |
constexpr char | kConfigOptionLogTimestampPrecision [] = "timestamp_precision" |
constexpr char | kConfigSectionLogger [] = "logger" |
constexpr char | kNone [] = "" |
constexpr char | kMainLogger [] = "main" |
Special names reserved for "main" program logger. More... | |
constexpr char | kMainLogHandler [] = "main_log_handler" |
constexpr char | kMainConsoleHandler [] = "main_console_handler" |
constexpr char | kSqlLogger [] = "sql" |
constexpr char | kDefaultLogFilename [] = "mysqlrouter.log" |
Default log filename. More... | |
const LogLevel | kDefaultLogLevel = LogLevel::kWarning |
Default log level used by the router. More... | |
const char *const | kDefaultLogLevelName = "warning" |
Log level name for the default log level used by the router. More... | |
const char *const | kRawLogLevelName = "info" |
Log level name used in raw logging mode. More... | |
static std::string | g_main_app_log_domain |
|
strong |
Log level values.
Log levels are ordered numerically from most important (lowest value) to least important (highest value).
|
strong |
void mysql_harness::logging::attach_handler_to_all_loggers | ( | Registry & | registry, |
std::string | name | ||
) |
Attach handler to all loggers.
registry | Registry object, typically managed by DIM |
name | Logger id (log domain it services) |
void mysql_harness::logging::clear_registry | ( | Registry & | registry | ) |
Clear registry.
Removes all Loggers and removes all references to Handlers (they're held as shared pointers, which may mean they will also be deleted)
registry | Registry object, typically managed by DIM |
void mysql_harness::logging::create_logger | ( | Registry & | registry, |
const LogLevel | level, | ||
const std::string & | logger_name | ||
) |
void mysql_harness::logging::create_main_log_handler | ( | Registry & | registry, |
const std::string & | program, | ||
const std::string & | logging_folder, | ||
bool | format_messages, | ||
bool | use_os_log = false |
||
) |
Initialize logfile handler.
Initializes handler which will handle application's log. This handler will be attached to all currently-registered loggers. If logging_folder
is provided, handler will log messages to logfile; its path and filename will be derived from program
and logging_folder
parameters. If logging_folder
is empty, handler will log messages to console, unless use_os_log
is set to true, in which case it will log to system logger instead (i.e. Syslog, Windows Eventlog, etc. Currently, only Windows Eventlog is supported).
registry | Registry object, typically managed by DIM |
program | Name of the main program (Router) |
logging_folder | logging_folder provided in configuration file |
format_messages | If set to true, log messages will be formatted (prefixed with log level, timestamp, etc) before logging |
use_os_log | If true, use system logger instead of STDERR (currently, only Windows Eventlog is supported) |
std::runtime_error | if opening log file or OS log fails |
void mysql_harness::logging::create_module_loggers | ( | Registry & | registry, |
const LogLevel | level, | ||
const std::list< std::string > & | modules, | ||
const std::string & | main_app_log_domain | ||
) |
Initialize logging facility.
Initializes logging facility by creating and registering a logger for each given module. Loggers will have their log level set to the log level passed as a parameter.
create_main_log_handler()
)registry | Registry object, typically managed by DIM |
level | The log level of the logger |
modules | List of plugin names loaded |
main_app_log_domain | Log domain (logger id) to be used as the main program logger. This logger must exist, because log_*() functions might fail |
std::logic_error |
std::string mysql_harness::logging::get_default_log_filename | ( | const Config & | config | ) |
Get default log filename.
Fetches default log filename set in the configuration file
config | Configuration items from configuration file |
LogLevel mysql_harness::logging::get_default_log_level | ( | const Config & | config, |
bool | raw_mode = false |
||
) |
Get default log level.
Fetches default log level set in the configuration file
config | Configuration items from configuration file |
raw_mode | true if the default level should be for the raw mode, false otherwise |
std::invalid_argument | if [logger].level in configuration is invalid |
std::ostream * mysql_harness::logging::get_default_logger_stream | ( | ) |
Returns pointer to the default logger sink stream.
LogTimestampPrecision mysql_harness::logging::get_default_timestamp_precision | ( | const Config & | config | ) |
Get default timestamp precision.
Fetches default timestamp precision for logfiles
config | Configuration items from configuration file |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
HARNESS_EXPORT LogLevel mysql_harness::logging::log_level_from_string | ( | std::string | name | ) |
Converts string with log level description to LogLevel type.
name | string with log level description |
std::invalid_argument | if log level string is invalid |
|
inlinestatic |
bool mysql_harness::logging::log_level_is_handled | ( | LogLevel | level, |
const char * | domain | ||
) |
|
inlinestatic |
|
inlinestatic |
HARNESS_EXPORT LogTimestampPrecision mysql_harness::logging::log_timestamp_precision_from_string | ( | std::string | name | ) |
Converts string with log timestamp precision description to LogTimestampPrecision type.
name | string with log timestamp precision description |
std::invalid_argument | if log timestamp precision string is invalid |
|
inlinestatic |
void mysql_harness::logging::register_handler | ( | std::string | name, |
std::shared_ptr< Handler > | handler | ||
) |
Register handler for all plugins.
This will register a handler for all plugins that have been registered with the logging subsystem (normally all plugins that have been loaded by Loader
).
name | The name under which handler is registered |
handler | Shared pointer to dynamically allocated handler. |
For example, to register a custom handler from a plugin, you would do the following:
void mysql_harness::logging::set_log_level_for_all_handlers | ( | const Registry & | registry, |
LogLevel | level | ||
) |
Set log levels for all handlers to specified value.
registry | Registry object, typically managed by DIM |
level | Log level for logger |
void mysql_harness::logging::set_log_level_for_all_handlers | ( | LogLevel | level | ) |
Set log level for all registered handlers.
void mysql_harness::logging::set_log_level_for_all_loggers | ( | LogLevel | level | ) |
Set log level for all registered loggers.
Set log levels for all the loggers to specified value.
registry | Registry object, typically managed by DIM |
level | Log level for logger |
void mysql_harness::logging::set_timestamp_precision_for_all_loggers | ( | LogTimestampPrecision | precision | ) |
void mysql_harness::logging::set_timestamp_precision_for_all_loggers | ( | Registry & | registry, |
LogTimestampPrecision | precision | ||
) |
Set timestamp precision for all the loggers.
registry | Registry object, typically managed by DIM |
precision | Precision of timestamps |
HARNESS_EXPORT void mysql_harness::logging::set_timestamp_precison_for_all_loggers | ( | LogTimestampPrecision | precision | ) |
Set timestamp precision for all registered loggers.
void mysql_harness::logging::unregister_handler | ( | std::string | name | ) |
Unregister a handler.
This will unregister a previously registered handler.
name | name of registered handler. |
|
static |
|
constexpr |
|
constexpr |
Section name and option name used in config file (and later in configuration object) to specify log level, best explained by example:
v--------------------— kConfigSectionLogger [logger] v---------------------— kConfigOptionLogLevel level = DEBUG v---------------------— kConfigOptionLogFilename filename = foo.log v---------------------— kConfigOptionLogTimestampPrecision timestamp_precision = second|sec|s|millisecond|msec|ms| microsecond|usec|us|nanosecond|nsec|ns
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
Default log filename.
const LogLevel mysql_harness::logging::kDefaultLogLevel = LogLevel::kWarning |
Default log level used by the router.
const char* const mysql_harness::logging::kDefaultLogLevelName = "warning" |
Log level name for the default log level used by the router.
const size_t mysql_harness::logging::kLogMessageMaxSize = 4096 |
Max message length that can be logged; if message is longer, it will be truncated to this length.
|
constexpr |
|
constexpr |
Special names reserved for "main" program logger.
It will use one of the two handlers, depending on whether logging_folder is empty or not.
|
constexpr |
|
constexpr |
const char* const mysql_harness::logging::kRawLogLevelName = "info" |
Log level name used in raw logging mode.
|
constexpr |