MySQL 8.3.0
Source Code Documentation
logger.h
Go to the documentation of this file.
1#ifndef LOGGER_UTIL_INCLUDED
2#define LOGGER_UTIL_INCLUDED
3/*
4 Copyright (c) 2015, 2023, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is also distributed with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have included with MySQL.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25*/
26
27#include <stddef.h>
28#include <ostream>
29#include <sstream>
30#include <string>
31
32struct Datetime {};
33
34std::ostream &operator<<(std::ostream &os, const Datetime &dt);
35
37 public:
38 explicit Gen_spaces(int s) { m_spaces.assign(s, ' '); }
39 std::ostream &operator<<(std::ostream &os) { return os; }
40 friend std::ostream &operator<<(std::ostream &os, const Gen_spaces &gen);
41
42 private:
43 std::string m_spaces;
44};
45
46std::ostream &operator<<(std::ostream &os, const Gen_spaces &gen);
47
48class Log : public std::ostream {
49 public:
50 Log(std::ostream &str, std::string logclass)
51 : std::ostream(nullptr), m_buffer(str, logclass) {
52 this->init(&m_buffer);
53 }
54 void enabled(bool s) { m_buffer.enabled(s); }
55
56 private:
57 class Log_buff : public std::stringbuf {
58 public:
59 Log_buff(std::ostream &str, std::string &logc)
60 : m_os(str), m_logc(logc), m_enabled(true) {}
61 void set_log_class(std::string &s) { m_logc = s; }
62 void enabled(bool s) { m_enabled = s; }
63 bool is_enabled() { return m_enabled; }
64 int sync() override;
65
66 private:
67 std::ostream &m_os;
68 std::string m_logc;
70 };
71
73};
74
75#endif /* LOGGER_UTIL_INCLUDED */
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:570
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:250
Definition: logger.h:36
friend std::ostream & operator<<(std::ostream &os, const Gen_spaces &gen)
Gen_spaces(int s)
Definition: logger.h:38
std::ostream & operator<<(std::ostream &os)
Definition: logger.h:39
std::string m_spaces
Definition: logger.h:43
Definition: logger.h:57
bool m_enabled
Definition: logger.h:69
void enabled(bool s)
Definition: logger.h:62
std::ostream & m_os
Definition: logger.h:67
Log_buff(std::ostream &str, std::string &logc)
Definition: logger.h:59
bool is_enabled()
Definition: logger.h:63
std::string m_logc
Definition: logger.h:68
void set_log_class(std::string &s)
Definition: logger.h:61
int sync() override
Definition: logger.cc:51
Definition: logger.h:48
Log(std::ostream &str, std::string logclass)
Definition: logger.h:50
Log_buff m_buffer
Definition: logger.h:72
void enabled(bool s)
Definition: logger.h:54
std::ostream & operator<<(std::ostream &os, const Datetime &dt)
Definition: logger.cc:34
static char * stringbuf
Definition: lexyy.cc:926
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1065
Definition: varlen_sort.h:174
Definition: logger.h:32