MySQL 8.2.0
Source Code Documentation
eventlog_plugin.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef MYSQL_HARNESS_EVENTLOG_PLUGIN_INCLUDED
26#define MYSQL_HARNESS_EVENTLOG_PLUGIN_INCLUDED
27
30#include "mysql/harness/plugin.h"
31
32constexpr const char *kEventlogPluginName = "eventlog";
33constexpr const char *kDefaultEventSourceName = "MySQL Router";
34extern "C" mysql_harness::Plugin harness_plugin_eventlog;
35
36/**
37 * Windows specific logging handler(sink) that writes the logs to the Windows
38 * eventlog.
39 */
41 public:
42 static constexpr const char *kDefaultName = "eventlog";
43
44 /** @brief Constructor
45 *
46 * It adds appropriate entries to the Windows registry and registers the
47 * Router as the event log messages source.
48 *
49 * @param format_messages flag indicating if the logged messages should be
50 * formatted
51 * @param level minimal log level for the handler
52 * @param create_registry_entries If true, initialisation will perform extra
53 * steps (which may potentially fail, thus you might prefer to disable
54 * them for mission-critical usage)
55 * @param event_source_name the event source name for event log entries
56 *
57 * @throw std::runtime_error on WinAPI calls failures
58 */
60 bool format_messages, mysql_harness::logging::LogLevel level,
61 bool create_registry_entries = true,
62 const std::string event_source_name = kDefaultEventSourceName);
63
64 ~EventlogHandler() override;
65
66 // does nothing for the eventlog handler
67 void reopen(const std::string dst [[maybe_unused]] = "") override {}
68
69 private:
70 void do_log(const mysql_harness::logging::Record &record) noexcept override;
71
73
74 const std::string event_source_name_;
75};
76
77#endif
Windows specific logging handler(sink) that writes the logs to the Windows eventlog.
Definition: eventlog_plugin.h:40
void do_log(const mysql_harness::logging::Record &record) noexcept override
Log message handler primitive.
Definition: eventlog_plugin.cc:161
~EventlogHandler() override
Definition: eventlog_plugin.cc:159
HANDLE event_src_
Definition: eventlog_plugin.h:72
const std::string event_source_name_
Definition: eventlog_plugin.h:74
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:142
void reopen(const std::string dst="") override
Request to reopen underlying log sink.
Definition: eventlog_plugin.h:67
static constexpr const char * kDefaultName
Definition: eventlog_plugin.h:42
Base class for log message handler.
Definition: handler.h:49
mysql_harness::Plugin harness_plugin_eventlog
Definition: eventlog_plugin.h:34
constexpr const char * kDefaultEventSourceName
Definition: eventlog_plugin.h:33
constexpr const char * kEventlogPluginName
Definition: eventlog_plugin.h:32
Logging interface for using and extending the logging subsystem.
static int record
Definition: mysqltest.cc:194
LogLevel
Log level values.
Definition: logging.h:95
Log record containing information collected by the logging system.
Definition: logging.h:182
#define HANDLE
Definition: violite.h:158