ClikaRT::logging::Logger
class
Header: ClikaRT/logging/logging.h
ClikaRT's logger: a configurable logging channel that is always present and always able to emit at any level (debug included), separate from whatever logging the host application uses. Verbosity is set at runtime; the default is Debug in debug builds and Info in release, overridable via the CLIKA_RT_LOG_VERBOSITY environment variable (see ClikaRT/common/env_vars.h).
Create your own named channels with get_logger("my-name"); the default channel is logger() (named "ClikaRT").
Macros
#define CLIKART_LOG_FORMAT_
#define CLIKART_LOG_FORMAT_(...) ::ClikaRT::logging::detail::log_format(__VA_ARGS__)
Declared in ClikaRT/logging/logging.h, line 185
#define CLIKART_LOG_AT
#define CLIKART_LOG_AT(level_, method_, ...) do { \ const ::ClikaRT::logging::Logger clikart_lg_ = ::ClikaRT::logging::logger(); \ if (clikart_lg_.should_log(level_)) \ clikart_lg_.method_(CLIKART_LOG_FORMAT_(__VA_ARGS__)); \ } while (0)
Declared in ClikaRT/logging/logging.h, line 188
#define CLIKART_LOG_TRACE
#define CLIKART_LOG_TRACE(...) CLIKART_LOG_AT(::ClikaRT::logging::LogLevel::Trace, trace, __VA_ARGS__)
Declared in ClikaRT/logging/logging.h, line 195
#define CLIKART_LOG_DEBUG
#define CLIKART_LOG_DEBUG(...) CLIKART_LOG_AT(::ClikaRT::logging::LogLevel::Debug, debug, __VA_ARGS__)
Declared in ClikaRT/logging/logging.h, line 196
#define CLIKART_LOG_INFO
#define CLIKART_LOG_INFO(...) CLIKART_LOG_AT(::ClikaRT::logging::LogLevel::Info, info, __VA_ARGS__)
Declared in ClikaRT/logging/logging.h, line 197
#define CLIKART_LOG_WARN
#define CLIKART_LOG_WARN(...) CLIKART_LOG_AT(::ClikaRT::logging::LogLevel::Warn, warn, __VA_ARGS__)
Declared in ClikaRT/logging/logging.h, line 198
#define CLIKART_LOG_ERROR
#define CLIKART_LOG_ERROR(...) CLIKART_LOG_AT(::ClikaRT::logging::LogLevel::Error, error, __VA_ARGS__)
Declared in ClikaRT/logging/logging.h, line 199
A handle to a logging channel. Copyable and cheap (shares the channel). All methods take an already-formatted message; use the CLIKART_LOG_* macros (or std::format) to build it; should_log lets a caller skip formatting work when the level is disabled.
Member functions
log()
void log(LogLevel level, std::string_view message) const
Emit message at level (dropped below the channel threshold).
Declared in ClikaRT/logging/logging.h, line 63
trace()
void trace(std::string_view message) const
Emit at Trace.
Declared in ClikaRT/logging/logging.h, line 65
debug()
void debug(std::string_view message) const
Emit at Debug.
Declared in ClikaRT/logging/logging.h, line 67
info()
void info(std::string_view message) const
Emit at Info.
Declared in ClikaRT/logging/logging.h, line 69
warn()
void warn(std::string_view message) const
Emit at Warn.
Declared in ClikaRT/logging/logging.h, line 71
error()
void error(std::string_view message) const
Emit at Error.
Declared in ClikaRT/logging/logging.h, line 73
set_level()
void set_level(LogLevel level) const
Set / read this channel's minimum level at runtime.
Declared in ClikaRT/logging/logging.h, line 76
level()
LogLevel level() const
the current threshold
Declared in ClikaRT/logging/logging.h, line 77
should_log()
bool should_log(LogLevel level) const
True if a message at level would be emitted (cheap pre-check).
Declared in ClikaRT/logging/logging.h, line 79
name()
std::string name() const
this channel's name
Declared in ClikaRT/logging/logging.h, line 81
add_file_handler()
void add_file_handler(std::string_view path) const
Also write this channel's records to path (appended to existing handlers).
Declared in ClikaRT/logging/logging.h, line 87
add_callback_handler()
void add_callback_handler(std::function<void(LogLevel, std::string_view)> callback) const
Also deliver each formatted record to callback(level, line) (the line has no trailing newline). The callback must be cheap and must not log back to this channel. A throw from it is contained in your own runtime and swallowed; the sink fires under the sink lock, from whichever thread logged, and must never unwind into the library.
Declared in ClikaRT/logging/logging.h, line 94