MySQL 9.0.0
Source Code Documentation
|
Base class for log message handler. More...
#include <handler.h>
Public Member Functions | |
Handler ()=default | |
Handler (const Handler &)=default | |
Handler & | operator= (const Handler &)=default |
virtual | ~Handler ()=default |
void | handle (const Record &record) |
void | set_level (LogLevel level) |
LogLevel | get_level () const |
void | set_timestamp_precision (LogTimestampPrecision precision) |
virtual void | reopen (const std::string dst="")=0 |
Request to reopen underlying log sink. More... | |
bool | has_logged () const |
check if the handler has logged at least one record. More... | |
Static Public Attributes | |
static constexpr const char * | kDefaultName = nullptr |
Default identifier. More... | |
Protected Member Functions | |
std::string | format (const Record &record) const |
Handler (bool format_messages, LogLevel level, LogTimestampPrecision timestamp_precision) | |
void | has_logged (bool v) |
Private Member Functions | |
virtual void | do_log (const Record &record)=0 |
Log message handler primitive. More... | |
Private Attributes | |
bool | format_messages_ |
Flags if log messages should be formatted (prefixed with log level, timestamp, etc) before logging. More... | |
LogLevel | level_ |
Log level set for the handler. More... | |
LogTimestampPrecision | precision_ |
Timestamp precision for logging. More... | |
bool | has_logged_ {false} |
Base class for log message handler.
This class is used to implement a log message handler. You need to implement the do_log
primitive to process the log record. If, for some reason, the implementation is unable to log the record, and exception can be thrown that will be caught by the harness.
|
explicitdefault |
|
explicitdefault |
|
virtualdefault |
|
explicitprotected |
|
privatepure virtual |
Log message handler primitive.
This member function is implemented by subclasses to properly log a record wherever it need to be logged. If it is not possible to log the message properly, an exception should be thrown and will be caught by the caller.
record | Record containing information about the message. |
Implemented in EventlogHandler, SyslogHandler, mysql_harness::logging::StreamHandler, mysql_harness::logging::NullHandler, and mysql_harness::logging::FileHandler.
|
protected |
|
inline |
void mysql_harness::logging::Handler::handle | ( | const Record & | record | ) |
|
inline |
check if the handler has logged at least one record.
true | if at least one record was logged |
false | if no record has been logged yet. |
|
inlineprotected |
|
pure virtual |
Request to reopen underlying log sink.
Should be no-op for handlers NOT writing to a file. Useful for log rotation, when the logger got the signal with the request to reopen the file. Provide a destination filename for the old file for file based handlers.
Implemented in EventlogHandler, mysql_harness::logging::FileHandler, mysql_harness::logging::StreamHandler, mysql_harness::logging::NullHandler, and SyslogHandler.
|
inline |
|
inline |
|
private |
Flags if log messages should be formatted (prefixed with log level, timestamp, etc) before logging.
|
private |
|
staticconstexpr |
Default identifier.
Every handler provides a default name which could be used as key in registry to uniquely identify it. There is no obligation to use it, it is only supplied for convenience. In case of many instances of the same handler, using a key derived from this default (such as "my_handler:instance1") is suggested.
This field should be set in derived classes
|
private |
Log level set for the handler.
|
private |
Timestamp precision for logging.