11 inline Logger::Logger(
const std::string& name,
const std::shared_ptr<Processor>& sink) : _name(name), _sink(sink)
15 inline Logger::~Logger()
20 template <
typename... T>
21 inline void Logger::Log(
Level level,
bool format, fmt::format_string<T...> message, T&&... args)
const
24 thread_local uint64_t thread = CppCommon::Thread::CurrentThreadId();
26 thread_local
Record record;
32 record.timestamp = CppCommon::Timestamp::utc();
33 record.thread = thread;
35 record.logger = _name;
38 if (_sink && _sink->IsStarted())
41 if (!_sink->FilterRecord(record))
46 record.Format(message, std::forward<T>(args)...);
48 record.StoreFormat(message, std::forward<T>(args)...);
51 _sink->ProcessRecord(record);
55 template <
typename... T>
56 inline void Logger::Debug(fmt::format_string<T...> message, T&&... args)
const
61 Log(Level::DEBUG,
false, message, std::forward<T>(args)...);
65 template <
typename... T>
66 inline void Logger::Info(fmt::format_string<T...> message, T&&... args)
const
68 Log(Level::INFO,
false, message, std::forward<T>(args)...);
71 template <
typename... T>
72 inline void Logger::Warn(fmt::format_string<T...> message, T&&... args)
const
74 Log(Level::WARN,
false, message, std::forward<T>(args)...);
77 template <
typename... T>
78 inline void Logger::Error(fmt::format_string<T...> message, T&&... args)
const
80 Log(Level::ERROR,
false, message, std::forward<T>(args)...);
83 template <
typename... T>
84 inline void Logger::Fatal(fmt::format_string<T...> message, T&&... args)
const
86 Log(Level::FATAL,
false, message, std::forward<T>(args)...);
89 inline void Logger::Flush()
91 if (_sink && _sink->IsStarted())
Logger()
Initialize default logger.
void Clear()
Clear logging record.
C++ Logging project definitions.