26#ifndef MYSQL_HARNESS_LOGGER_HANDLER_INCLUDED
27#define MYSQL_HARNESS_LOGGER_HANDLER_INCLUDED
29#include "harness_export.h"
63 static constexpr const char *kDefaultName =
nullptr;
76 precision_ = precision;
85 virtual void reopen(
const std::string dst =
"") = 0;
132 bool has_logged_{
false};
146 static constexpr const char *kDefaultName =
"stream";
148 explicit StreamHandler(std::ostream &stream,
bool format_messages =
true,
154 void reopen(
const std::string )
override {}
177 static constexpr const char *kDefaultName =
"null";
185 void reopen(
const std::string )
override {}
202 static constexpr const char *kDefaultName =
"file";
210 void reopen(
const std::string dst =
"")
override;
Class representing a path in a file system.
Definition: filesystem.h:63
Handler that writes to a file.
Definition: handler.h:200
std::ofstream fstream_
Definition: handler.h:216
const Path file_path_
Definition: handler.h:215
Base class for log message handler.
Definition: handler.h:50
void set_timestamp_precision(LogTimestampPrecision precision)
Definition: handler.h:75
void has_logged(bool v)
Definition: handler.h:101
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:130
LogLevel level_
Log level set for the handler.
Definition: handler.h:125
bool format_messages_
Flags if log messages should be formatted (prefixed with log level, timestamp, etc) before logging.
Definition: handler.h:120
Handler(const Handler &)=default
LogLevel get_level() const
Definition: handler.h:74
void set_level(LogLevel level)
Definition: handler.h:73
Handler & operator=(const Handler &)=default
bool has_logged() const
check if the handler has logged at least one record.
Definition: handler.h:93
Handler to write to a null device such as /dev/null (unix) or NUL (windows).
Definition: handler.h:175
void reopen(const std::string) override
Request to reopen underlying log sink.
Definition: handler.h:185
Handler to write to an output stream.
Definition: handler.h:144
void reopen(const std::string) override
Request to reopen underlying log sink.
Definition: handler.h:154
std::ostream & stream_
Definition: handler.h:157
std::mutex stream_mutex_
Definition: handler.h:158
Logging interface for using and extending the logging subsystem.
static char * path
Definition: mysqldump.cc:149
static int record
Definition: mysqltest.cc:195
LogLevel
Log level values.
Definition: logging.h:90
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:64
Log record containing information collected by the logging system.
Definition: logging.h:182