ChainCLI
A modern C++20 command-line interface library
Loading...
Searching...
No Matches
cli::logging::AbstractLogger Class Referenceabstract

Abstract base class for logger implementations. More...

#include <logger.h>

Inheritance diagram for cli::logging::AbstractLogger:
cli::logging::Logger

Public Member Functions

virtual void setLevel (LogLevel lvl)=0
 Set the minimum log level for this logger.
 
virtual void addHandler (std::unique_ptr< AbstractHandler > handlerPtr)=0
 Add a log handler.
 
virtual void removeAllHandlers ()=0
 Remove all log handlers.
 
virtual void log (LogLevel lvl, const std::string &message) const =0
 Log a message at the specified log level.
 
virtual std::ostream & getStream (LogLevel lvl)=0
 Get the stream for the specified log level.
 
template<typename... Args>
void log (LogLevel lvl, const std::string &fmt, Args &&...args) const
 Log a message at the specified log level using a format string to print the passed arguments.
 
template<typename... Args>
void trace (const std::string &fmt, Args &&...args)
 Log a message at the TRACE level.
 
template<typename... Args>
void verbose (const std::string &fmt, Args &&...args)
 Log a message at the VERBOSE level.
 
template<typename... Args>
void debug (const std::string &fmt, Args &&...args)
 Log a message at the DEBUG level.
 
template<typename... Args>
void success (const std::string &fmt, Args &&...args)
 Log a message at the SUCCESS level.
 
template<typename... Args>
void info (const std::string &fmt, Args &&...args)
 Log a message at the INFO level.
 
template<typename... Args>
void warning (const std::string &fmt, Args &&...args)
 Log a message at the WARNING level.
 
template<typename... Args>
void error (const std::string &fmt, Args &&...args)
 Log a message at the ERROR level.
 
std::ostream & trace ()
 Get the stream for the TRACE log level.
 
std::ostream & verbose ()
 Get the stream for the VERBOSE log level.
 
std::ostream & debug ()
 Get the stream for the DEBUG log level.
 
std::ostream & success ()
 Get the stream for the SUCCESS log level.
 
std::ostream & info ()
 Get the stream for the INFO log level.
 
std::ostream & warning ()
 Get the stream for the WARNING log level.
 
std::ostream & error ()
 Get the stream for the ERROR log level.
 

Detailed Description

Abstract base class for logger implementations.

Member Function Documentation

◆ addHandler()

virtual void cli::logging::AbstractLogger::addHandler ( std::unique_ptr< AbstractHandler handlerPtr)
pure virtual

Add a log handler.

Parameters
handlerPtrThe log handler to add

Implemented in cli::logging::Logger.

◆ debug() [1/2]

std::ostream & cli::logging::AbstractLogger::debug ( )
inline

Get the stream for the DEBUG log level.

Returns
The output stream for the DEBUG log level

◆ debug() [2/2]

template<typename... Args>
void cli::logging::AbstractLogger::debug ( const std::string &  fmt,
Args &&...  args 
)
inline

Log a message at the DEBUG level.

Template Parameters
...ArgsThe argument types for the format string
Parameters
fmtThe format string
...argsThe arguments for the format string

◆ error() [1/2]

std::ostream & cli::logging::AbstractLogger::error ( )
inline

Get the stream for the ERROR log level.

Returns
The output stream for the ERROR log level

◆ error() [2/2]

template<typename... Args>
void cli::logging::AbstractLogger::error ( const std::string &  fmt,
Args &&...  args 
)
inline

Log a message at the ERROR level.

Template Parameters
...ArgsThe argument types for the format string
Parameters
fmtThe format string
...argsThe arguments for the format string

◆ getStream()

virtual std::ostream & cli::logging::AbstractLogger::getStream ( LogLevel  lvl)
pure virtual

Get the stream for the specified log level.

Parameters
lvlThe log level
Returns
The output stream for the specified log level

Implemented in cli::logging::Logger.

◆ info() [1/2]

std::ostream & cli::logging::AbstractLogger::info ( )
inline

Get the stream for the INFO log level.

Returns
The output stream for the INFO log level

◆ info() [2/2]

template<typename... Args>
void cli::logging::AbstractLogger::info ( const std::string &  fmt,
Args &&...  args 
)
inline

Log a message at the INFO level.

Template Parameters
...ArgsThe argument types for the format string
Parameters
fmtThe format string
...argsThe arguments for the format string

◆ log() [1/2]

template<typename... Args>
void cli::logging::AbstractLogger::log ( LogLevel  lvl,
const std::string &  fmt,
Args &&...  args 
) const
inline

Log a message at the specified log level using a format string to print the passed arguments.

Template Parameters
...ArgsThe argument types for the format string
Parameters
lvlThe log level for this message
fmtThe format string
...argsThe arguments for the format string

◆ log() [2/2]

virtual void cli::logging::AbstractLogger::log ( LogLevel  lvl,
const std::string &  message 
) const
pure virtual

Log a message at the specified log level.

Parameters
lvlThe log level
messageThe message to log

Implemented in cli::logging::Logger.

◆ removeAllHandlers()

virtual void cli::logging::AbstractLogger::removeAllHandlers ( )
pure virtual

Remove all log handlers.

Implemented in cli::logging::Logger.

◆ setLevel()

virtual void cli::logging::AbstractLogger::setLevel ( LogLevel  lvl)
pure virtual

Set the minimum log level for this logger.

Parameters
lvlThe new minimum log level

Implemented in cli::logging::Logger.

◆ success() [1/2]

std::ostream & cli::logging::AbstractLogger::success ( )
inline

Get the stream for the SUCCESS log level.

Returns
The output stream for the SUCCESS log level

◆ success() [2/2]

template<typename... Args>
void cli::logging::AbstractLogger::success ( const std::string &  fmt,
Args &&...  args 
)
inline

Log a message at the SUCCESS level.

Template Parameters
...ArgsThe argument types for the format string
Parameters
fmtThe format string
...argsThe arguments for the format string

◆ trace() [1/2]

std::ostream & cli::logging::AbstractLogger::trace ( )
inline

Get the stream for the TRACE log level.

Returns
The output stream for the TRACE log level

◆ trace() [2/2]

template<typename... Args>
void cli::logging::AbstractLogger::trace ( const std::string &  fmt,
Args &&...  args 
)
inline

Log a message at the TRACE level.

Template Parameters
...ArgsThe argument types for the format string
Parameters
fmtThe format string
...argsThe arguments for the format string

◆ verbose() [1/2]

std::ostream & cli::logging::AbstractLogger::verbose ( )
inline

Get the stream for the VERBOSE log level.

Returns
The output stream for the VERBOSE log level

◆ verbose() [2/2]

template<typename... Args>
void cli::logging::AbstractLogger::verbose ( const std::string &  fmt,
Args &&...  args 
)
inline

Log a message at the VERBOSE level.

Template Parameters
...ArgsThe argument types for the format string
Parameters
fmtThe format string
...argsThe arguments for the format string

◆ warning() [1/2]

std::ostream & cli::logging::AbstractLogger::warning ( )
inline

Get the stream for the WARNING log level.

Returns
The output stream for the WARNING log level

◆ warning() [2/2]

template<typename... Args>
void cli::logging::AbstractLogger::warning ( const std::string &  fmt,
Args &&...  args 
)
inline

Log a message at the WARNING level.

Template Parameters
...ArgsThe argument types for the format string
Parameters
fmtThe format string
...argsThe arguments for the format string

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