MySQL 8.3.0
Source Code Documentation
logger_plugin.cc File Reference
#include "mysql/harness/logging/logger_plugin.h"
#include <sstream>
#include <vector>
#include "consolelog_plugin.h"
#include "dim.h"
#include "filelog_plugin.h"
#include "mysql/harness/logging/supported_logger_options.h"
#include "mysql/harness/string_utils.h"
#include "mysql/harness/utility/string.h"
#include "syslog_plugin.h"

Namespaces

namespace  anonymous_namespace{logger_plugin.cc}
 

Macros

#define MYSQL_ROUTER_LOG_DOMAIN   "logger"
 
#define NULL_DEVICE_NAME   "/dev/null"
 
#define STDOUT_DEVICE_NAME   "/dev/stdout"
 
#define STDERR_DEVICE_NAME   "/dev/stderr"
 
#define LEGAL_DESTINATION_DEVICE_NAMES    NULL_DEVICE_NAME ", " STDOUT_DEVICE_NAME ", " STDERR_DEVICE_NAME
 

Typedefs

using HandlerPtr = std::shared_ptr< mysql_harness::logging::Handler >
 
using LoggerHandlersList = std::vector< std::pair< std::string, HandlerPtr > >
 

Functions

static bool legal_consolelog_destination (const std::string &destination)
 
HandlerPtr anonymous_namespace{logger_plugin.cc}::create_logging_sink (const std::string &sink_name, const mysql_harness::LoaderConfig &config, const std::string &default_log_filename, const mysql_harness::logging::LogLevel default_log_level, const mysql_harness::logging::LogTimestampPrecision default_log_timestamp_precision)
 
void create_plugin_loggers (const mysql_harness::LoaderConfig &config, mysql_harness::logging::Registry &registry, const mysql_harness::logging::LogLevel level)
 Creates the logging handler for each plugin from the configuration. More...
 
void register_on_switch_to_configured_loggers_callback (on_switch_to_configured_loggers callback)
 Registers the callback that the plugin will execute once it is finished with initialization and switches from the default to the configured logger sink(s). More...
 
static bool init_handlers (mysql_harness::PluginFuncEnv *env, const mysql_harness::LoaderConfig &config, LoggerHandlersList &logger_handlers)
 
static void switch_to_loggers_in_config (const mysql_harness::LoaderConfig &config, const LoggerHandlersList &logger_handlers)
 
static void init (mysql_harness::PluginFuncEnv *env)
 

Variables

std::vector< on_switch_to_configured_loggersg_on_switch_to_configured_loggers_clbs
 
mysql_harness::Plugin harness_plugin_logger
 

Macro Definition Documentation

◆ LEGAL_DESTINATION_DEVICE_NAMES

#define LEGAL_DESTINATION_DEVICE_NAMES    NULL_DEVICE_NAME ", " STDOUT_DEVICE_NAME ", " STDERR_DEVICE_NAME

◆ MYSQL_ROUTER_LOG_DOMAIN

#define MYSQL_ROUTER_LOG_DOMAIN   "logger"

◆ NULL_DEVICE_NAME

#define NULL_DEVICE_NAME   "/dev/null"

◆ STDERR_DEVICE_NAME

#define STDERR_DEVICE_NAME   "/dev/stderr"

◆ STDOUT_DEVICE_NAME

#define STDOUT_DEVICE_NAME   "/dev/stdout"

Typedef Documentation

◆ HandlerPtr

using HandlerPtr = std::shared_ptr<mysql_harness::logging::Handler>

◆ LoggerHandlersList

using LoggerHandlersList = std::vector<std::pair<std::string, HandlerPtr> >

Function Documentation

◆ create_plugin_loggers()

void create_plugin_loggers ( const mysql_harness::LoaderConfig config,
mysql_harness::logging::Registry registry,
const mysql_harness::logging::LogLevel  level 
)

Creates the logging handler for each plugin from the configuration.

Parameters
configconfiguration containing the plugin names we should create loggers for
registrylogging registry where the logging handlers should be created
levellogging level for the newly create logging handlers
Exceptions
std::logic_error

◆ init()

static void init ( mysql_harness::PluginFuncEnv env)
static

◆ init_handlers()

static bool init_handlers ( mysql_harness::PluginFuncEnv env,
const mysql_harness::LoaderConfig config,
LoggerHandlersList logger_handlers 
)
static

◆ legal_consolelog_destination()

static bool legal_consolelog_destination ( const std::string &  destination)
inlinestatic

◆ register_on_switch_to_configured_loggers_callback()

void register_on_switch_to_configured_loggers_callback ( on_switch_to_configured_loggers  callback)

Registers the callback that the plugin will execute once it is finished with initialization and switches from the default to the configured logger sink(s).

Parameters
callbackcallback to execute

◆ switch_to_loggers_in_config()

static void switch_to_loggers_in_config ( const mysql_harness::LoaderConfig config,
const LoggerHandlersList logger_handlers 
)
static

Variable Documentation

◆ g_on_switch_to_configured_loggers_clbs

std::vector<on_switch_to_configured_loggers> g_on_switch_to_configured_loggers_clbs

◆ harness_plugin_logger

mysql_harness::Plugin harness_plugin_logger
Initial value:
= {
mysql_harness::PLUGIN_ABI_VERSION,
mysql_harness::ARCHITECTURE_DESCRIPTOR,
"Logger",
VERSION_NUMBER(0, 0, 1),
0,
nullptr,
0,
nullptr,
init,
nullptr,
nullptr,
nullptr,
false,
}
static void init(mysql_harness::PluginFuncEnv *env)
Definition: logger_plugin.cc:422
static constexpr std::array< const char *, 5 > logger_supported_options
Definition: supported_logger_options.h:38