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

Console log handler. More...

#include <handler.h>

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

Public Member Functions

 ConsoleHandler (std::shared_ptr< AbstractFormatter > formatter, LogLevel minLevel=LogLevel::DEBUG, std::shared_ptr< const LogStyleMap > styles=std::make_shared< LogStyleMap >(defaultStyles()))
 Construct a new Console Handler that uses std::cout and std::cerr.
 
- Public Member Functions inherited from 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)
 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).
 

Additional Inherited Members

- Protected Attributes inherited from cli::logging::BaseHandler
std::ostream & out
 
std::ostream & err
 

Detailed Description

Console log handler.

Constructor & Destructor Documentation

◆ ConsoleHandler()

cli::logging::ConsoleHandler::ConsoleHandler ( std::shared_ptr< AbstractFormatter formatter,
LogLevel  minLevel = LogLevel::DEBUG,
std::shared_ptr< const LogStyleMap >  styles = std::make_shared<LogStyleMap>(defaultStyles()) 
)
inlineexplicit

Construct a new Console Handler that uses std::cout and std::cerr.

Parameters
formatterThe formatter to use for log messages
minLevelThe minimum log level for this handler
stylesThe styles to use for log messages

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