MySQL 8.0.39
Source Code Documentation
log_client.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
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, version 2.0, 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#ifndef LOG_H_
25#define LOG_H_
26
27#include <stdio.h>
28#include <iostream>
29#include <sstream>
30
32 typedef enum {
38};
39
46};
47
49 public:
50 template <log_client_type::log_type type>
51 void log(std::string msg);
53 void write(std::string data);
54 void log_client_plugin_data_exchange(const unsigned char *buffer,
55 unsigned int length);
56
57 private:
59};
60
61template <log_client_type::log_type type>
62void Logger_client::log(std::string msg) {
63 std::stringstream log_stream;
64 switch (type) {
67 return;
68 }
69 log_stream << "[DBG] ";
70 break;
73 return;
74 }
75 log_stream << "[Note] ";
76 break;
79 return;
80 }
81 log_stream << "[Warning] ";
82 break;
85 return;
86 }
87 log_stream << "[Error] ";
88 break;
89 };
90
91 /*
92 We can write debug messages also in error log file if logging level is set
93 to debug. For MySQL client this will come from environment variable
94 */
95 log_stream << ": " << msg;
96 write(log_stream.str());
97}
98
100
101#define log_client_dbg g_logger_client->log<log_client_type::LOG_CLIENT_DBG>
102#define log_client_info g_logger_client->log<log_client_type::LOG_CLIENT_INFO>
103#define log_client_warning g_logger->log<log_client_type::LOG_CLIENT_WARNING>
104#define log_client_error g_logger_client->log<log_client_type::LOG_CLIENT_ERROR>
105
106#endif
Logger_client * g_logger_client
Definition: auth_kerberos_client_plugin.cc:52
log_client_level
Definition: log_client.h:40
@ LOG_CLIENT_LEVEL_ERROR_WARNING_INFO
Definition: log_client.h:44
@ LOG_CLIENT_LEVEL_ERROR
Definition: log_client.h:42
@ LOG_CLIENT_LEVEL_ERROR_WARNING
Definition: log_client.h:43
@ LOG_CLIENT_LEVEL_NONE
Definition: log_client.h:41
@ LOG_CLIENT_LEVEL_ALL
Definition: log_client.h:45
Definition: log_client.h:48
void set_log_level(log_client_level level)
Definition: log_client.cc:26
log_client_level m_log_level
Definition: log_client.h:58
void write(std::string data)
Definition: log_client.cc:30
void log(std::string msg)
Definition: log_client.h:62
void log_client_plugin_data_exchange(const unsigned char *buffer, unsigned int length)
Definition: log_client.cc:35
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:420
required string type
Definition: replication_group_member_actions.proto:34
Definition: log_client.h:31
log_type
Definition: log_client.h:32
@ LOG_CLIENT_ERROR
Definition: log_client.h:36
@ LOG_CLIENT_DBG
Definition: log_client.h:33
@ LOG_CLIENT_WARNING
Definition: log_client.h:35
@ LOG_CLIENT_INFO
Definition: log_client.h:34