50 std::shared_ptr<AbstractFormatter> formatter, LogLevel minLevel = LogLevel::DEBUG,
51 std::shared_ptr<const LogStyleMap> styles =
nullptr)
52 : out(outStream), err(errStream), formatterPtr(std::move(formatter)),
53 styleMapPtr(std::move(styles)), minLevel(minLevel)
67 void setStyleMap(std::shared_ptr<const LogStyleMap> styles);
73 bool stylingEnabled{
true};
74 std::shared_ptr<AbstractFormatter> formatterPtr;
75 std::shared_ptr<const LogStyleMap> styleMapPtr;
88 std::shared_ptr<AbstractFormatter> formatter, LogLevel minLevel = LogLevel::DEBUG,
89 std::shared_ptr<const LogStyleMap> styles = std::make_shared<LogStyleMap>(defaultStyles()))
90 :
BaseHandler(std::cout, std::cerr, formatter, minLevel, std::move(styles))
104 explicit FileHandler(
const std::string &filename, std::shared_ptr<AbstractFormatter> formatter,
105 LogLevel minLevel = LogLevel::DEBUG,
106 std::shared_ptr<const LogStyleMap> styles =
nullptr);
Interface for log record handlers.
Definition handler.h:30
virtual void emit(const LogRecord &record) const =0
Emit a log record, using the handlers formatter and specified output.
Basic log handler that writes to specified output streams.
Definition handler.h:41
void setStyleMap(std::shared_ptr< const LogStyleMap > styles)
Attach a style map (for ANSI colors).
Definition handler.cpp:53
void emit(const LogRecord &record) const override
Emit a log record, using the handlers formatter and specified output.
Definition handler.cpp:27
void setStylingEnabled(bool enabled)
Enable or disable styling for log messages.
Definition handler.h:63
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.
Definition handler.h:49
Console log handler.
Definition handler.h:81
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.
Definition handler.h:87
File log handler.
Definition handler.h:97
Data structure representing a log record.
Definition logrecord.h:28