CppLogging 1.0.5.0
C++ Logging Library
Loading...
Searching...
No Matches
logger.h
Go to the documentation of this file.
1
9#ifndef CPPLOGGING_LOGGER_H
10#define CPPLOGGING_LOGGER_H
11
12#include "logging/processors.h"
13
14namespace CppLogging {
15
17
22class Logger
23{
24 friend class Config;
25
26public:
28 Logger();
30
33 explicit Logger(const std::string& name);
34 Logger(const Logger&) = default;
35 Logger(Logger&&) = default;
36 ~Logger();
37
38 Logger& operator=(const Logger&) = default;
39 Logger& operator=(Logger&&) = default;
40
42
47 void Debug(std::string_view message) const { Debug("{}", message); }
49
55 template <typename... T>
56 void Debug(fmt::format_string<T...> message, T&&... args) const;
57
59
62 void Info(std::string_view message) const { Info("{}", message); }
64
68 template <typename... T>
69 void Info(fmt::format_string<T...> message, T&&... args) const;
70
72
75 void Warn(std::string_view message) const { Warn("{}", message); }
77
81 template <typename... T>
82 void Warn(fmt::format_string<T...> message, T&&... args) const;
83
85
88 void Error(std::string_view message) const { Error("{}", message); }
90
94 template <typename... T>
95 void Error(fmt::format_string<T...> message, T&&... args) const;
96
98
101 void Fatal(std::string_view message) const { Fatal("{}", message); }
103
107 template <typename... T>
108 void Fatal(fmt::format_string<T...> message, T&&... args) const;
109
111 void Flush();
112
114 void Update();
115
116private:
117 std::string _name;
118 std::shared_ptr<Processor> _sink;
119
121
125 explicit Logger(const std::string& name, const std::shared_ptr<Processor>& sink);
126
128
134 template <typename... T>
135 void Log(Level level, bool format, fmt::format_string<T...> message, T&&... args) const;
136};
137
138} // namespace CppLogging
139
140#include "logger.inl"
141
145#endif // CPPLOGGING_LOGGER_H
Logger configuration static class.
Definition config.h:25
Logger interface.
Definition logger.h:23
Logger(const Logger &)=default
void Warn(std::string_view message) const
Log warning message.
Definition logger.h:75
void Flush()
Flush the current logger.
Definition logger.inl:89
Logger(Logger &&)=default
Logger & operator=(const Logger &)=default
Logger()
Initialize default logger.
Definition logger.cpp:15
void Debug(std::string_view message) const
Log debug message.
Definition logger.h:47
void Fatal(std::string_view message) const
Log fatal message.
Definition logger.h:101
void Error(std::string_view message) const
Log error message.
Definition logger.h:88
void Info(std::string_view message) const
Log information message.
Definition logger.h:62
void Update()
Update the current logger sink by taking the most recent one from configuration.
Definition logger.cpp:23
Logger & operator=(Logger &&)=default
Logger interface inline implementation.
C++ Logging project definitions.
Definition appender.h:15
Level
Logging level.
Definition level.h:18
Logging processors definition.