MySQL 9.0.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, 2024, 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 designed to work 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 either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26*/
27
28#include <stddef.h>
29#include <ostream>
30#include <sstream>
31#include <string>
32
33struct Datetime {};
34
35std::ostream &operator<<(std::ostream &os, const Datetime &dt);
36
38 public:
39 explicit Gen_spaces(int s) { m_spaces.assign(s, ' '); }
40 std::ostream &operator<<(std::ostream &os) { return os; }
41 friend std::ostream &operator<<(std::ostream &os, const Gen_spaces &gen);
42
43 private:
44 std::string m_spaces;
45};
46
47std::ostream &operator<<(std::ostream &os, const Gen_spaces &gen);
48
49class Log : public std::ostream {
50 public:
51 Log(std::ostream &str, std::string logclass)
52 : std::ostream(nullptr), m_buffer(str, logclass) {
53 this->init(&m_buffer);
54 }
55 void enabled(bool s) { m_buffer.enabled(s); }
56
57 private:
58 class Log_buff : public std::stringbuf {
59 public:
60 Log_buff(std::ostream &str, std::string &logc)
61 : m_os(str), m_logc(logc), m_enabled(true) {}
62 void set_log_class(std::string &s) { m_logc = s; }
63 void enabled(bool s) { m_enabled = s; }
64 bool is_enabled() { return m_enabled; }
65 int sync() override;
66
67 private:
68 std::ostream &m_os;
69 std::string m_logc;
71 };
72
74};
75
76#endif /* LOGGER_UTIL_INCLUDED */
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:571
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Definition: logger.h:37
friend std::ostream & operator<<(std::ostream &os, const Gen_spaces &gen)
Gen_spaces(int s)
Definition: logger.h:39
std::ostream & operator<<(std::ostream &os)
Definition: logger.h:40
std::string m_spaces
Definition: logger.h:44
Definition: logger.h:58
bool m_enabled
Definition: logger.h:70
void enabled(bool s)
Definition: logger.h:63
std::ostream & m_os
Definition: logger.h:68
Log_buff(std::ostream &str, std::string &logc)
Definition: logger.h:60
bool is_enabled()
Definition: logger.h:64
std::string m_logc
Definition: logger.h:69
void set_log_class(std::string &s)
Definition: logger.h:62
int sync() override
Definition: logger.cc:52
Definition: logger.h:49
Log(std::ostream &str, std::string logclass)
Definition: logger.h:51
Log_buff m_buffer
Definition: logger.h:73
void enabled(bool s)
Definition: logger.h:55
std::ostream & operator<<(std::ostream &os, const Datetime &dt)
Definition: logger.cc:35
static char * stringbuf
Definition: lexyy.cc:926
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
Definition: gcs_xcom_synode.h:64
Definition: logger.h:33