Lugdunum  0.1.0
Handler.cpp
Go to the documentation of this file.
4 
5 namespace lug {
6 namespace System {
7 namespace Logger {
8 
9 Handler::Handler(const std::string& name) :
10  _name(name),
11  _formatter(std::make_unique<Formatter>("[%H:%M:%S][%l] %v\n")),
12  _level(Level::Debug) {}
13 
14 void Handler::setFormatter(std::unique_ptr<Formatter> formatter) {
15  _formatter = std::move(formatter);
16 }
17 
18 void Handler::setPattern(const std::string& formatter) {
19  _formatter = std::make_unique<Formatter>(formatter);
20 }
21 
22 void Handler::format(priv::Message& msg) {
23  _formatter->format(msg);
24 }
25 
26 void Handler::setLevel(Level level) {
27  _level = level;
28 }
29 
31  return _level;
32 }
33 
34 bool Handler::shouldLog(Level level) const {
35  return level >= _level;
36 }
37 
38 } // Logger
39 } // System
40 } // lug
bool shouldLog(Level level) const
Definition: Handler.cpp:34
Handler(const std::string &name)
Definition: Handler.cpp:9
void setFormatter(std::unique_ptr< Formatter > formatter)
Definition: Handler.cpp:14
void format(priv::Message &msg)
Definition: Handler.cpp:22
void setLevel(Level level)
Definition: Handler.cpp:26
priv::make_unique_if< T >::SingleObject make_unique(Arena &arena, Args &&... args)
std::unique_ptr< Formatter > _formatter
Definition: Handler.hpp:40
void setPattern(const std::string &pattern)
Definition: Handler.cpp:18