MySQL 8.0.39
Source Code Documentation
eventlog_plugin.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018, 2024, 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_EVENTLOG_PLUGIN_INCLUDED
27#define MYSQL_HARNESS_EVENTLOG_PLUGIN_INCLUDED
28
31#include "mysql/harness/plugin.h"
32
33constexpr const char *kEventlogPluginName = "eventlog";
34constexpr const char *kDefaultEventSourceName = "MySQL Router";
35extern "C" mysql_harness::Plugin harness_plugin_eventlog;
36
37/**
38 * Windows specific logging handler(sink) that writes the logs to the Windows
39 * eventlog.
40 */
42 public:
43 static constexpr const char *kDefaultName = "eventlog";
44
45 /** @brief Constructor
46 *
47 * It adds appropriate entries to the Windows registry and registers the
48 * Router as the event log messages source.
49 *
50 * @param format_messages flag indicating if the logged messages should be
51 * formatted
52 * @param level minimal log level for the handler
53 * @param create_registry_entries If true, initialisation will perform extra
54 * steps (which may potentially fail, thus you might prefer to disable
55 * them for mission-critical usage)
56 * @param event_source_name the event source name for event log entries
57 *
58 * @throw std::runtime_error on WinAPI calls failures
59 */
61 bool format_messages, mysql_harness::logging::LogLevel level,
62 bool create_registry_entries = true,
63 const std::string event_source_name = kDefaultEventSourceName);
64
65 ~EventlogHandler() override;
66
67 // does nothing for the eventlog handler
68 void reopen(const std::string dst [[maybe_unused]] = "") override {}
69
70 private:
71 void do_log(const mysql_harness::logging::Record &record) noexcept override;
72
74
75 const std::string event_source_name_;
76};
77
78#endif
Windows specific logging handler(sink) that writes the logs to the Windows eventlog.
Definition: eventlog_plugin.h:41
void do_log(const mysql_harness::logging::Record &record) noexcept override
Log message handler primitive.
Definition: eventlog_plugin.cc:162
~EventlogHandler() override
Definition: eventlog_plugin.cc:160
HANDLE event_src_
Definition: eventlog_plugin.h:73
const std::string event_source_name_
Definition: eventlog_plugin.h:75
EventlogHandler(bool format_messages, mysql_harness::logging::LogLevel level, bool create_registry_entries=true, const std::string event_source_name=kDefaultEventSourceName)
Constructor.
Definition: eventlog_plugin.cc:143
void reopen(const std::string dst="") override
Request to reopen underlying log sink.
Definition: eventlog_plugin.h:68
static constexpr const char * kDefaultName
Definition: eventlog_plugin.h:43
Base class for log message handler.
Definition: handler.h:50
mysql_harness::Plugin harness_plugin_eventlog
Definition: eventlog_plugin.h:35
constexpr const char * kDefaultEventSourceName
Definition: eventlog_plugin.h:34
constexpr const char * kEventlogPluginName
Definition: eventlog_plugin.h:33
Logging interface for using and extending the logging subsystem.
static int record
Definition: mysqltest.cc:188
LogLevel
Log level values.
Definition: logging.h:96
Log record containing information collected by the logging system.
Definition: logging.h:183
#define HANDLE
Definition: violite.h:159