Logger¶
-
class Logger¶
Process-wide logging facility with a pluggable handler.
A thin wrapper around four severity levels that by default prints to
stdout. Call set_log_handler to redirect messages elsewhere, for example into a host application’s own logging system; clear_log_handler restores the default printer.Public Types
-
enum LogLevel¶
Severity of a logged message.
Values:
-
enumerator level_debug¶
-
enumerator level_info¶
-
enumerator level_warning¶
-
enumerator level_error¶
-
enumerator level_debug¶
-
using LogHandlerFunc = std::function<void(LogLevel level, const std::string &message)>¶
Signature of a custom log handler; see set_log_handler.
Public Static Functions
-
static inline void log(LogLevel level, const std::string &message)¶
Dispatch
messageatlevelto the current handler, or print it.
-
static inline void debug(const std::string &message)¶
Log
messageatlevel_debug.
-
static inline void info(const std::string &message)¶
Log
messageatlevel_info.
-
static inline void warning(const std::string &message)¶
Log
messageatlevel_warning.
-
static inline void error(const std::string &message)¶
Log
messageatlevel_error.
-
static inline void set_log_handler(LogHandlerFunc func)¶
Route every future log call through
funcinstead of printing.
-
static inline void clear_log_handler()¶
Remove a handler set with set_log_handler and resume printing.
-
enum LogLevel¶