11inline Logger::Logger(
const std::string& name,
const std::shared_ptr<Processor>& sink) : _name(name), _sink(sink)
20template <
typename... T>
21inline 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();
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);
55template <
typename... T>
56inline void Logger::Debug(fmt::format_string<T...> message, T&&... args)
const
61 Log(
Level::DEBUG,
false, message, std::forward<T>(args)...);
65template <
typename... T>
66inline void Logger::Info(fmt::format_string<T...> message, T&&... args)
const
68 Log(
Level::INFO,
false, message, std::forward<T>(args)...);
71template <
typename... T>
72inline void Logger::Warn(fmt::format_string<T...> message, T&&... args)
const
74 Log(
Level::WARN,
false, message, std::forward<T>(args)...);
77template <
typename... T>
78inline void Logger::Error(fmt::format_string<T...> message, T&&... args)
const
80 Log(
Level::ERROR,
false, message, std::forward<T>(args)...);
83template <
typename... T>
84inline void Logger::Fatal(fmt::format_string<T...> message, T&&... args)
const
86 Log(
Level::FATAL,
false, message, std::forward<T>(args)...);
91 if (_sink && _sink->IsStarted())
void Warn(std::string_view message) const
Log warning message.
void Flush()
Flush the current logger.
Logger()
Initialize default logger.
void Debug(std::string_view message) const
Log debug message.
void Fatal(std::string_view message) const
Log fatal message.
void Error(std::string_view message) const
Log error message.
void Info(std::string_view message) const
Log information message.
void Clear()
Clear logging record.
Level level
Level of the logging record.
uint64_t thread
Thread Id of the logging record.
std::string logger
Logger name of the logging record.
Record & Format(fmt::format_string< T... > pattern, T &&... args)
Format message and its arguments.
uint64_t timestamp
Timestamp of the logging record.
Record & StoreFormat(fmt::format_string< T... > pattern, T &&... args)
Store format message and its arguments.
C++ Logging project definitions.