MySQL 26.10.0
Source Code Documentation
componentlog_plugin.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2026, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQL_HARNESS_COMPONENTLOG_PLUGIN_INCLUDED
27#define MYSQL_HARNESS_COMPONENTLOG_PLUGIN_INCLUDED
28
29#include "harness_export.h"
30
31#include <mysql/components/services/log_builtins.h> // For LogEvent
34#include "mysql/harness/plugin.h"
35
36constexpr const char kComponentlogPluginName[] = "componentlog";
37
38extern "C" {
39extern mysql_harness::Plugin harness_plugin_componentlog;
40}
41
42/**
43 * Specific logging handler(sink) that writes the logs using the Component
44 * Logging primitives
45 */
46class HARNESS_EXPORT ComponentlogHandler final
48 public:
49 explicit ComponentlogHandler(bool format_messages = true,
52 : mysql_harness::logging::Handler(
53 format_messages, level,
54 mysql_harness::logging::LogTimestampPrecision::kSec) {}
55 ~ComponentlogHandler() override = default;
56
61
62 // does nothing for the componentlog handler
63 void reopen(const std::string /*dst*/) override {}
64
65 static void init_log_service(SERVICE_TYPE(log_builtins) * log_builtins_ptr,
66 SERVICE_TYPE(log_builtins_string) *
67 log_builtins_string_ptr);
68 static bool is_initialized() { return s_inited; }
69
70 private:
71 void do_log(const mysql_harness::logging::Record &record) noexcept override;
72 static loglevel log_level_to_component_log_level(
74
75 static bool s_inited;
76};
77
78#endif // MYSQL_HARNESS_COMPONENTLOG_PLUGIN_INCLUDED
Specific logging handler(sink) that writes the logs using the Component Logging primitives.
Definition: componentlog_plugin.h:47
ComponentlogHandler(ComponentlogHandler &&)=delete
~ComponentlogHandler() override=default
ComponentlogHandler & operator=(ComponentlogHandler &&)=delete
ComponentlogHandler(const ComponentlogHandler &)=delete
void reopen(const std::string) override
Request to reopen underlying log sink.
Definition: componentlog_plugin.h:63
ComponentlogHandler(bool format_messages=true, mysql_harness::logging::LogLevel level=mysql_harness::logging::LogLevel::kNotSet)
Definition: componentlog_plugin.h:49
static bool is_initialized()
Definition: componentlog_plugin.h:68
static bool s_inited
Definition: componentlog_plugin.h:75
ComponentlogHandler & operator=(const ComponentlogHandler &)=delete
Base class for log message handler.
Definition: handler.h:50
virtual void do_log(const Record &record)=0
Log message handler primitive.
constexpr const char kComponentlogPluginName[]
Definition: componentlog_plugin.h:36
mysql_harness::Plugin harness_plugin_componentlog
Definition: componentlog_plugin.cc:111
Logging interface for using and extending the logging subsystem.
loglevel
Definition: my_loglevel.h:41
static int record
Definition: mysqltest.cc:195
LogLevel
Log level values.
Definition: logging.h:90
LogTimestampPrecision
Log timestamp precision values.
Definition: logging.h:160
Singleton class that stores the application type.
Definition: component_application_type_name.h:31
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:76
Log record containing information collected by the logging system.
Definition: logging.h:182