MySQL 8.0.37
Source Code Documentation
log_client.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 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:
52 void write(std::string data);
53};
54
56 public:
59 template <ldap_log_type::ldap_type type>
60 void log(std::string msg);
61 void set_log_level(ldap_log_level level);
62
63 private:
66};
67
68template <ldap_log_type::ldap_type type>
69void Ldap_logger::log(std::string msg) {
70 std::stringstream log_stream;
71 switch (type) {
74 return;
75 }
76 log_stream << "[DBG] ";
77 break;
80 return;
81 }
82 log_stream << "[Note] ";
83 break;
86 return;
87 }
88 log_stream << "[Warning] ";
89 break;
92 return;
93 }
94 log_stream << "[Error] ";
95 break;
96 };
97
98 /** We can write debug messages also in error log file if logging level is set
99 to debug. For MySQL client this will come from environment variable */
100 if (m_log_writer) {
101 log_stream << ": " << msg;
102 m_log_writer->write(log_stream.str());
103 }
104}
105
107
108#define log_dbg g_logger_client->log<ldap_log_type::LDAP_LOG_DBG>
109#define log_info g_logger_client->log<ldap_log_type::LDAP_LOG_INFO>
110#define log_warning g_logger->log<ldap_log_type::LDAP_LOG_WARNING>
111#define log_error g_logger_client->log<ldap_log_type::LDAP_LOG_ERROR>
112
113#endif
Logger_client * g_logger_client
Definition: auth_kerberos_client_plugin.cc:52
ldap_log_level
Definition: log_client.h:40
@ LDAP_LOG_LEVEL_ERROR
Definition: log_client.h:42
@ LDAP_LOG_LEVEL_ERROR_WARNING_INFO
Definition: log_client.h:44
@ LDAP_LOG_LEVEL_ERROR_WARNING
Definition: log_client.h:43
@ LDAP_LOG_LEVEL_NONE
Definition: log_client.h:41
@ LDAP_LOG_LEVEL_ALL
Definition: log_client.h:45
Definition: log_client.h:48
void write(std::string data)
Definition: log_client.cc:40
Ldap_log_writer_error()
This class writes error into default error streams.
Definition: log_client.h:55
~Ldap_logger()
Definition: log_client.cc:32
ldap_log_level m_log_level
Definition: log_client.h:65
void log(std::string msg)
Definition: log_client.h:69
Ldap_logger()
Definition: log_client.cc:26
Ldap_log_writer_error * m_log_writer
Definition: log_client.h:64
void set_log_level(ldap_log_level level)
Definition: log_client.cc:38
required string type
Definition: replication_group_member_actions.proto:34
Definition: log_client.h:31
ldap_type
Definition: log_client.h:32
@ LDAP_LOG_WARNING
Definition: log_client.h:35
@ LDAP_LOG_INFO
Definition: log_client.h:34
@ LDAP_LOG_DBG
Definition: log_client.h:33
@ LDAP_LOG_ERROR
Definition: log_client.h:36