OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::logging::log Class Reference

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.
 

Detailed Description

Generalized logging class.

Supports logging to stdout or an output file at a specified log level.

Definition at line 51 of file logging.hpp.

Constructor & Destructor Documentation

◆ log()

cbdc::logging::log::log ( log_level level,
bool use_stdout = true,
std::unique_ptr< std::ostream > logfile = std::make_unique<null_stream>() )
explicit

Creates a new log instance.

By default, logs to stdout and a null_stream.

Parameters
levelthe log level (and above) to print to the logger(s).
use_stdoutindicates if the logger should print to stdout.
logfilea pointer to a logfile stream.

Definition at line 11 of file logging.cpp.

Member Function Documentation

◆ debug()

template<typename... Targs>
void cbdc::logging::log::debug ( Targs &&... args)
inline

Writes the argument list to the debug log level.

Definition at line 89 of file logging.hpp.

References cbdc::logging::debug.

◆ error()

template<typename... Targs>
void cbdc::logging::log::error ( Targs &&... args)
inline

Writes the argument list to the error log level.

Definition at line 108 of file logging.hpp.

References cbdc::logging::error.

◆ fatal()

template<typename... Targs>
void cbdc::logging::log::fatal ( Targs &&... args)
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.

◆ flush()

void cbdc::logging::log::flush ( )
static

Flushes the log buffer.

Definition at line 66 of file logging.cpp.

◆ get_log_level()

auto cbdc::logging::log::get_log_level ( ) const -> log_level
nodiscard

Returns the current log level of the logger.

Returns
the current log level.

Definition at line 30 of file logging.cpp.

◆ info()

template<typename... Targs>
void cbdc::logging::log::info ( Targs &&... args)
inline

Writes the argument list to the info log level.

Definition at line 96 of file logging.hpp.

References cbdc::logging::info.

◆ set_logfile()

void cbdc::logging::log::set_logfile ( std::unique_ptr< std::ostream > logfile)

Changes the logfile output to another destination.

Parameters
logfilethe stream to which to write log output.

Definition at line 22 of file logging.cpp.

◆ set_loglevel()

void cbdc::logging::log::set_loglevel ( log_level level)

Changes the log level threshold.

Parameters
levelanything for this log level and more severe will be logged to the configured outputs.

Definition at line 26 of file logging.cpp.

◆ set_stdout_enabled()

void cbdc::logging::log::set_stdout_enabled ( bool stdout_enabled)

Enables or disables printing the log output to stdout.

Parameters
stdout_enabledtrue if the log should print to stdout.

Definition at line 18 of file logging.cpp.

◆ trace()

template<typename... Targs>
void cbdc::logging::log::trace ( Targs &&... args)
inline

Writes the argument list to the trace log level.

Definition at line 82 of file logging.hpp.

References cbdc::logging::trace.

◆ warn()

template<typename... Targs>
void cbdc::logging::log::warn ( Targs &&... args)
inline

Writes the argument list to the warn log level.

Definition at line 102 of file logging.hpp.

References cbdc::logging::warn.


The documentation for this class was generated from the following files: