OpenCBDC Transaction Processor
|
Generalized logging class. More...
#include <logging.hpp>
Public Member Functions | |
log (log_level level, bool use_stdout=true, std::unique_ptr< std::ostream > logfile=std::make_unique< null_stream >()) | |
Creates a new log instance. | |
void | set_stdout_enabled (bool stdout_enabled) |
Enables or disables printing the log output to stdout. | |
void | set_logfile (std::unique_ptr< std::ostream > logfile) |
Changes the logfile output to another destination. | |
void | set_loglevel (log_level level) |
Changes the log level threshold. | |
template<typename... Targs> | |
void | trace (Targs &&... args) |
Writes the argument list to the trace log level. | |
template<typename... Targs> | |
void | debug (Targs &&... args) |
Writes the argument list to the debug log level. | |
template<typename... Targs> | |
void | info (Targs &&... args) |
Writes the argument list to the info log level. | |
template<typename... Targs> | |
void | warn (Targs &&... args) |
Writes the argument list to the warn log level. | |
template<typename... Targs> | |
void | error (Targs &&... args) |
Writes the argument list to the error log level. | |
template<typename... Targs> | |
void | fatal (Targs &&... args) |
Writes the argument list to the fatal log level. | |
auto | get_log_level () const -> log_level |
Returns the current log level of the logger. | |
Static Public Member Functions | |
static void | flush () |
Flushes the log buffer. | |
Generalized logging class.
Supports logging to stdout or an output file at a specified log level.
Definition at line 51 of file logging.hpp.
|
explicit |
Creates a new log instance.
By default, logs to stdout and a null_stream.
level | the log level (and above) to print to the logger(s). |
use_stdout | indicates if the logger should print to stdout. |
logfile | a pointer to a logfile stream. |
Definition at line 11 of file logging.cpp.
|
inline |
Writes the argument list to the debug log level.
Definition at line 89 of file logging.hpp.
References cbdc::logging::debug.
|
inline |
Writes the argument list to the error log level.
Definition at line 108 of file logging.hpp.
References cbdc::logging::error.
|
inline |
Writes the argument list to the fatal log level.
Calls exit to terminate the program.
Definition at line 116 of file logging.hpp.
References cbdc::logging::fatal.
|
static |
Flushes the log buffer.
Definition at line 66 of file logging.cpp.
|
nodiscard |
Returns the current log level of the logger.
Definition at line 30 of file logging.cpp.
|
inline |
Writes the argument list to the info log level.
Definition at line 96 of file logging.hpp.
References cbdc::logging::info.
void cbdc::logging::log::set_logfile | ( | std::unique_ptr< std::ostream > | logfile | ) |
Changes the logfile output to another destination.
logfile | the stream to which to write log output. |
Definition at line 22 of file logging.cpp.
void cbdc::logging::log::set_loglevel | ( | log_level | level | ) |
Changes the log level threshold.
level | anything for this log level and more severe will be logged to the configured outputs. |
Definition at line 26 of file logging.cpp.
void cbdc::logging::log::set_stdout_enabled | ( | bool | stdout_enabled | ) |
Enables or disables printing the log output to stdout.
stdout_enabled | true if the log should print to stdout. |
Definition at line 18 of file logging.cpp.
|
inline |
Writes the argument list to the trace log level.
Definition at line 82 of file logging.hpp.
References cbdc::logging::trace.
|
inline |
Writes the argument list to the warn log level.
Definition at line 102 of file logging.hpp.
References cbdc::logging::warn.