MySQL 9.1.0
Source Code Documentation
EventlogHandler Class Referencefinal

Windows specific logging handler(sink) that writes the logs to the Windows eventlog. More...

#include <eventlog_plugin.h>

Inheritance diagram for EventlogHandler:
[legend]

Public Member Functions

 EventlogHandler (bool format_messages, mysql_harness::logging::LogLevel level, bool create_registry_entries=true, const std::string event_source_name=kDefaultEventSourceName)
 Constructor. More...
 
 ~EventlogHandler () override
 
void reopen (const std::string dst="") override
 Request to reopen underlying log sink. More...
 
- Public Member Functions inherited from mysql_harness::logging::Handler
 Handler ()=default
 
 Handler (const Handler &)=default
 
Handleroperator= (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)
 
bool has_logged () const
 check if the handler has logged at least one record. More...
 

Static Public Attributes

static constexpr const char * kDefaultName = "eventlog"
 
- Static Public Attributes inherited from mysql_harness::logging::Handler
static constexpr const char * kDefaultName = nullptr
 Default identifier. More...
 

Private Member Functions

void do_log (const mysql_harness::logging::Record &record) noexcept override
 Log message handler primitive. More...
 

Private Attributes

HANDLE event_src_
 
const std::string event_source_name_
 

Additional Inherited Members

- Protected Member Functions inherited from mysql_harness::logging::Handler
std::string format (const Record &record) const
 
 Handler (bool format_messages, LogLevel level, LogTimestampPrecision timestamp_precision)
 
void has_logged (bool v)
 

Detailed Description

Windows specific logging handler(sink) that writes the logs to the Windows eventlog.

Constructor & Destructor Documentation

◆ EventlogHandler()

EventlogHandler::EventlogHandler ( bool  format_messages,
mysql_harness::logging::LogLevel  level,
bool  create_registry_entries = true,
const std::string  event_source_name = kDefaultEventSourceName 
)

Constructor.

It adds appropriate entries to the Windows registry and registers the Router as the event log messages source.

Parameters
format_messagesflag indicating if the logged messages should be formatted
levelminimal log level for the handler
create_registry_entriesIf true, initialisation will perform extra steps (which may potentially fail, thus you might prefer to disable them for mission-critical usage)
event_source_namethe event source name for event log entries
Exceptions
std::runtime_erroron WinAPI calls failures

◆ ~EventlogHandler()

EventlogHandler::~EventlogHandler ( )
override

Member Function Documentation

◆ do_log()

void EventlogHandler::do_log ( const mysql_harness::logging::Record record)
overrideprivatevirtualnoexcept

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.

Parameters
recordRecord containing information about the message.

Implements mysql_harness::logging::Handler.

◆ reopen()

void EventlogHandler::reopen ( const std::string  dst = "")
inlineoverridevirtual

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.

Implements mysql_harness::logging::Handler.

Member Data Documentation

◆ event_source_name_

const std::string EventlogHandler::event_source_name_
private

◆ event_src_

HANDLE EventlogHandler::event_src_
private

◆ kDefaultName

constexpr const char* EventlogHandler::kDefaultName = "eventlog"
staticconstexpr

The documentation for this class was generated from the following files: