MySQL 9.1.0
Source Code Documentation
|
#include <registry.h>
Public Member Functions | |
Registry ()=default | |
Registry (const Registry &)=delete | |
Registry & | operator= (const Registry &)=delete |
~Registry ()=default | |
void | create_logger (const std::string &name, LogLevel level=LogLevel::kNotSet) |
Create a logger in the internal registry. More... | |
void | remove_logger (const std::string &name) |
Remove a named logger from the internal registry. More... | |
Logger | get_logger (const std::string &name) const |
Return logger for particular module. More... | |
Logger | get_logger_or_default (const std::string &name, const std::string &default_name) const |
Return logger for particular module. More... | |
Logger | get_logger_or_default (const std::string &name) const |
Return logger for particular module. More... | |
void | update_logger (const std::string &name, const Logger &logger) |
Update logger for particular module. More... | |
std::set< std::string > | get_logger_names () const |
Get the logger names (id's) from the internal registry. More... | |
void | add_handler (std::string name, std::shared_ptr< Handler > handler) |
Add a handler to the internal registry. More... | |
void | remove_handler (std::string name) |
Remove handler from the internal registry. More... | |
std::shared_ptr< Handler > | get_handler (const std::string &name) const |
Return handler in the internal registry. More... | |
std::set< std::string > | get_handler_names () const |
Get the handler names from the internal registry. More... | |
bool | is_handled (LogLevel level) const |
Check if a log-level is handled by at least one handler. More... | |
void | set_ready () noexcept |
Flag that the registry has been initialized. More... | |
bool | is_ready () const noexcept |
Query if logging facility is ready to use. More... | |
void | flush_all_loggers (const std::string &dst="") |
Force the flush (reopen) on all registered logger handlers, while moving old logger file to dst. More... | |
Private Attributes | |
std::shared_mutex | mtx_ |
std::map< std::string, Logger > | loggers_ |
std::map< std::string, std::shared_ptr< Handler > > | handlers_ |
std::atomic< bool > | ready_ {false} |
|
default |
|
delete |
|
default |
void mysql_harness::logging::Registry::add_handler | ( | std::string | name, |
std::shared_ptr< Handler > | handler | ||
) |
Add a handler to the internal registry.
name | Handler id |
handler | Shared pointer to handler |
std::logic_error | if there is a handler already registered with given module name |
void mysql_harness::logging::Registry::create_logger | ( | const std::string & | name, |
LogLevel | level = LogLevel::kNotSet |
||
) |
Create a logger in the internal registry.
name | Logger id (log domain it services) |
level | Log level for logger |
std::logic_error | if there is a logger already registered with given module name |
void mysql_harness::logging::Registry::flush_all_loggers | ( | const std::string & | dst = "" | ) |
Force the flush (reopen) on all registered logger handlers, while moving old logger file to dst.
dst | destination filename for old log |
std::shared_ptr< Handler > mysql_harness::logging::Registry::get_handler | ( | const std::string & | name | ) | const |
Return handler in the internal registry.
name | Handler id |
std::logic_error | if no handler is registered for given name |
std::set< std::string > mysql_harness::logging::Registry::get_handler_names | ( | ) | const |
Get the handler names from the internal registry.
Logger mysql_harness::logging::Registry::get_logger | ( | const std::string & | name | ) | const |
Return logger for particular module.
The reason why this function returns by value is thread-safety.
name | Logger id (log domain it services) |
std::logic_error | if no logger is registered for given module name |
std::set< std::string > mysql_harness::logging::Registry::get_logger_names | ( | ) | const |
Get the logger names (id's) from the internal registry.
Logger mysql_harness::logging::Registry::get_logger_or_default | ( | const std::string & | name | ) | const |
Return logger for particular module.
if it doesn't exist, get the default logger.
name | Logger id (log domain it services) |
std::logic_error | if neither logger is registered for given module name |
Logger mysql_harness::logging::Registry::get_logger_or_default | ( | const std::string & | name, |
const std::string & | default_name | ||
) | const |
Return logger for particular module.
if it doesn't exist, get the default logger.
name | Logger id (log domain it services) |
default_name | name of the default logger |
std::logic_error | if neither logger is registered for given module name |
bool mysql_harness::logging::Registry::is_handled | ( | LogLevel | level | ) | const |
Check if a log-level is handled by at least one handler.
true | at least one handler |
false | log-level will be ignored. |
|
inlinenoexcept |
Query if logging facility is ready to use.
The exact meaning of this flag is not defined here, see description in set_ready()
void mysql_harness::logging::Registry::remove_handler | ( | std::string | name | ) |
Remove handler from the internal registry.
name | Handler id |
std::logic_error | if no handler is registered for given name |
void mysql_harness::logging::Registry::remove_logger | ( | const std::string & | name | ) |
Remove a named logger from the internal registry.
name | Logger id (log domain it services) |
std::logic_error | if there is no logger registered with given module name |
|
inlinenoexcept |
Flag that the registry has been initialized.
This method should be called after log initialization is complete to flag that logging facility is now available. Note that this is a convenience flag - it does not directly affect the operation of Registry. However, a logging function (i.e. log_message()) might want to query this flag when called and do whatever it deems appropriate.
void mysql_harness::logging::Registry::update_logger | ( | const std::string & | name, |
const Logger & | logger | ||
) |
Update logger for particular module.
This function provides a thread-safe way of updating the Logger object in the registry.
name | Logger id (log domain it services) |
logger | Logger object |
std::logic_error | if no logger is registered for given module name |
|
private |
|
private |
|
mutableprivate |
|
private |