MySQL 8.0.30
Source Code Documentation
log_client.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2022, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef LOG_H_
24#define LOG_H_
25
26#include <stdio.h>
27#include <iostream>
28#include <sstream>
29
31 typedef enum {
37};
38
45};
46
48 public:
51 void write(std::string data);
52};
53
55 public:
58 template <ldap_log_type::ldap_type type>
59 void log(std::string msg);
60 void set_log_level(ldap_log_level level);
61
62 private:
65};
66
67template <ldap_log_type::ldap_type type>
68void Ldap_logger::log(std::string msg) {
69 std::stringstream log_stream;
70 switch (type) {
73 return;
74 }
75 log_stream << "[DBG] ";
76 break;
79 return;
80 }
81 log_stream << "[Note] ";
82 break;
85 return;
86 }
87 log_stream << "[Warning] ";
88 break;
91 return;
92 }
93 log_stream << "[Error] ";
94 break;
95 };
96
97 /** We can write debug messages also in error log file if logging level is set
98 to debug. For MySQL client this will come from environment variable */
99 if (m_log_writer) {
100 log_stream << ": " << msg;
101 m_log_writer->write(log_stream.str());
102 }
103}
104
106
107#define log_dbg g_logger_client->log<ldap_log_type::LDAP_LOG_DBG>
108#define log_info g_logger_client->log<ldap_log_type::LDAP_LOG_INFO>
109#define log_warning g_logger->log<ldap_log_type::LDAP_LOG_WARNING>
110#define log_error g_logger_client->log<ldap_log_type::LDAP_LOG_ERROR>
111
112#endif
Logger_client * g_logger_client
Definition: auth_kerberos_client_plugin.cc:58
ldap_log_level
Definition: log_client.h:39
@ LDAP_LOG_LEVEL_ERROR
Definition: log_client.h:41
@ LDAP_LOG_LEVEL_ERROR_WARNING_INFO
Definition: log_client.h:43
@ LDAP_LOG_LEVEL_ERROR_WARNING
Definition: log_client.h:42
@ LDAP_LOG_LEVEL_NONE
Definition: log_client.h:40
@ LDAP_LOG_LEVEL_ALL
Definition: log_client.h:44
Definition: log_client.h:47
void write(std::string data)
Definition: log_client.cc:39
Ldap_log_writer_error()
This class writes error into default error streams.
Definition: log_client.h:54
~Ldap_logger()
Definition: log_client.cc:31
ldap_log_level m_log_level
Definition: log_client.h:64
void log(std::string msg)
Definition: log_client.h:68
Ldap_logger()
Definition: log_client.cc:25
Ldap_log_writer_error * m_log_writer
Definition: log_client.h:63
void set_log_level(ldap_log_level level)
Definition: log_client.cc:37
required string type
Definition: replication_group_member_actions.proto:33
Definition: log_client.h:30
ldap_type
Definition: log_client.h:31
@ LDAP_LOG_WARNING
Definition: log_client.h:34
@ LDAP_LOG_INFO
Definition: log_client.h:33
@ LDAP_LOG_DBG
Definition: log_client.h:32
@ LDAP_LOG_ERROR
Definition: log_client.h:35