25#ifndef MYSQL_HARNESS_LOGGER_HANDLER_INCLUDED
26#define MYSQL_HARNESS_LOGGER_HANDLER_INCLUDED
28#include "harness_export.h"
62 static constexpr const char *kDefaultName =
nullptr;
75 precision_ = precision;
84 virtual void reopen(
const std::string dst =
"") = 0;
131 bool has_logged_{
false};
145 static constexpr const char *kDefaultName =
"stream";
147 explicit StreamHandler(std::ostream &stream,
bool format_messages =
true,
153 void reopen(
const std::string )
override {}
176 static constexpr const char *kDefaultName =
"null";
184 void reopen(
const std::string )
override {}
201 static constexpr const char *kDefaultName =
"file";
209 void reopen(
const std::string dst =
"")
override;
Class representing a path in a file system.
Definition: filesystem.h:62
Handler that writes to a file.
Definition: handler.h:199
std::ofstream fstream_
Definition: handler.h:215
const Path file_path_
Definition: handler.h:214
Base class for log message handler.
Definition: handler.h:49
void set_timestamp_precision(LogTimestampPrecision precision)
Definition: handler.h:74
void has_logged(bool v)
Definition: handler.h:100
virtual ~Handler()=default
virtual void do_log(const Record &record)=0
Log message handler primitive.
virtual void reopen(const std::string dst="")=0
Request to reopen underlying log sink.
LogTimestampPrecision precision_
Timestamp precision for logging.
Definition: handler.h:129
LogLevel level_
Log level set for the handler.
Definition: handler.h:124
bool format_messages_
Flags if log messages should be formatted (prefixed with log level, timestamp, etc) before logging.
Definition: handler.h:119
Handler(const Handler &)=default
LogLevel get_level() const
Definition: handler.h:73
void set_level(LogLevel level)
Definition: handler.h:72
Handler & operator=(const Handler &)=default
bool has_logged() const
check if the handler has logged at least one record.
Definition: handler.h:92
Handler to write to a null device such as /dev/null (unix) or NUL (windows).
Definition: handler.h:174
void reopen(const std::string) override
Request to reopen underlying log sink.
Definition: handler.h:184
Handler to write to an output stream.
Definition: handler.h:143
void reopen(const std::string) override
Request to reopen underlying log sink.
Definition: handler.h:153
std::ostream & stream_
Definition: handler.h:156
std::mutex stream_mutex_
Definition: handler.h:157
Logging interface for using and extending the logging subsystem.
static char * path
Definition: mysqldump.cc:148
static int record
Definition: mysqltest.cc:194
LogLevel
Log level values.
Definition: logging.h:95
LogTimestampPrecision
Log timestamp precision values.
Definition: logging.h:160
static int handle(int sql_errno, const char *sqlstate, const char *message, void *state)
Bridge function between the C++ API offered by this module and the C API of the parser service.
Definition: services.cc:63
Log record containing information collected by the logging system.
Definition: logging.h:182