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

File log handler. More...

#include <handler.h>

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

Public Member Functions

 FileHandler (const std::string &filename, std::shared_ptr< AbstractFormatter > formatter, LogLevel minLevel=LogLevel::DEBUG, std::shared_ptr< const LogStyleMap > styles=nullptr)
 Construct a new File Handler that writes to the specified file.
 
- 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

File log handler.

Constructor & Destructor Documentation

◆ FileHandler()

inline_t cli::logging::FileHandler::FileHandler ( const std::string &  filename,
std::shared_ptr< AbstractFormatter formatter,
LogLevel  minLevel = LogLevel::DEBUG,
std::shared_ptr< const LogStyleMap >  styles = nullptr 
)
explicit

Construct a new File Handler that writes to the specified file.

Parameters
filenameThe name of the file to write to
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 files: