SNode.C
Loading...
Searching...
No Matches
Logger.h
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LOGGER_LOGGER_H
21#define LOGGER_LOGGER_H
22
23#ifndef DOXYGEN_SHOULD_SKIP_THIS
24
25#ifdef __GNUC__
26#pragma GCC diagnostic push
27#ifdef __has_warning
28#if __has_warning("-Wdocumentation-unknown-command")
29#pragma GCC diagnostic ignored "-Wdocumentation-unknown-command"
30#endif
31#endif
32#endif
33#include <easylogging++.h> // IWYU pragma: export
34#ifdef __GNUC__
35#pragma GCC diagnostic pop
36#endif
37
38#include <string>
39
40#endif /* DOXYGEN_SHOULD_SKIP_THIS */
41
42namespace Color {
43
44 enum class Code {
45 FG_DEFAULT = 39,
46 FG_BLACK = 30,
47 FG_RED = 31,
48 FG_GREEN = 32,
49 FG_YELLOW = 33,
50 FG_BLUE = 34,
51 FG_MAGENTA = 35,
52 FG_CYAN = 36,
53 FG_LIGHT_GRAY = 37,
54 FG_DARK_GRAY = 90,
55 FG_LIGHT_RED = 91,
56 FG_LIGHT_GREEN = 92,
57 FG_LIGHT_YELLOW = 93,
58 FG_LIGHT_BLUE = 94,
60 FG_LIGHT_CYAN = 96,
61 FG_WHITE = 97,
62 BG_RED = 41,
63 BG_GREEN = 42,
64 BG_BLUE = 44,
65 BG_DEFAULT = 49
66 };
67
69
70} // namespace Color
71
72namespace logger {
73
74 class Logger {
75 public:
76 Logger() = delete;
77 ~Logger() = delete;
78
79 // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, hicpp-avoid-c-arrays, modernize-avoid-c-arrays)
80 static void init();
81
82 static void setLogLevel(int level);
83
84 static void setVerboseLevel(int level);
85
86 static void logToFile(const std::string& logFile);
87
88 static void setQuiet(bool quiet = true);
89
90 static void setCustomFormatSpec(const char* format, const el::FormatSpecifierValueResolver& resolver);
91
92 protected:
93 // static el::Configurations conf;
94 };
95
96} // namespace logger
97
98#endif // LOGGER_LOGGER_H
static void logToFile(const std::string &logFile)
Definition Logger.cpp:105
static void setVerboseLevel(int level)
Definition Logger.cpp:99
static void setCustomFormatSpec(const char *format, const el::FormatSpecifierValueResolver &resolver)
Definition Logger.cpp:56
~Logger()=delete
static void setLogLevel(int level)
Definition Logger.cpp:62
static void init()
Definition Logger.cpp:32
static void setQuiet(bool quiet=true)
Definition Logger.cpp:114
Logger()=delete
int main(int argc, char *argv[])
Definition Logger.h:42
std::ostream & operator<<(std::ostream &os, Code code)
Definition Logger.cpp:124
Code
Definition Logger.h:44