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

Basic log handler that writes to specified output streams. More...

#include <handler.h>

Inheritance diagram for cli::logging::BaseHandler:
cli::logging::AbstractHandler cli::logging::ConsoleHandler cli::logging::FileHandler

Public Member Functions

 BaseHandler (std::ostream &outStream, std::ostream &errStream, std::shared_ptr< AbstractFormatter > formatter, LogLevel minLevel=LogLevel::DEBUG, std::shared_ptr< const LogStyleMap > styles=nullptr)
 Construct a new Base Handler using the given out and error streams.
 
void emit (const LogRecord &record) const override
 Emit a log record, using the handlers formatter and specified output.
 
void setStylingEnabled (bool enabled)
 Enable or disable styling for log messages.
 
void setStyleMap (std::shared_ptr< const LogStyleMap > styles)
 Attach a style map (for ANSI colors).
 

Protected Attributes

std::ostream & out
 
std::ostream & err
 

Detailed Description

Basic log handler that writes to specified output streams.

Constructor & Destructor Documentation

◆ BaseHandler()

cli::logging::BaseHandler::BaseHandler ( std::ostream &  outStream,
std::ostream &  errStream,
std::shared_ptr< AbstractFormatter formatter,
LogLevel  minLevel = LogLevel::DEBUG,
std::shared_ptr< const LogStyleMap >  styles = nullptr 
)
inline

Construct a new Base Handler using the given out and error streams.

Parameters
outStreamThe output stream for log messages
errStreamThe error stream for log messages
formatterThe formatter to use for log messages
minLevelThe minimum log level for this handler
stylesThe styles to use for log messages

Member Function Documentation

◆ emit()

inline_t void cli::logging::BaseHandler::emit ( const LogRecord record) const
overridevirtual

Emit a log record, using the handlers formatter and specified output.

Parameters
recordThe log record to emit.

Implements cli::logging::AbstractHandler.

◆ setStyleMap()

inline_t void cli::logging::BaseHandler::setStyleMap ( std::shared_ptr< const LogStyleMap >  styles)

Attach a style map (for ANSI colors).

Parameters
stylesThe styles to use for log messages.

◆ setStylingEnabled()

void cli::logging::BaseHandler::setStylingEnabled ( bool  enabled)
inline

Enable or disable styling for log messages.

Parameters
enabledWhether styling should be enabled.

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