Lugdunum  0.1.0
Handler.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <atomic>
4 #include <memory>
5 #include <lug/System/Export.hpp>
10 
11 namespace lug {
12 namespace System {
13 namespace Logger {
14 
16 public:
17  explicit Handler(const std::string& name);
18 
19  Handler(const Handler&) = delete;
20  Handler(Handler&&) = delete;
21 
22  Handler& operator=(const Handler&) = delete;
23  Handler& operator=(Handler&&) = delete;
24 
25  virtual ~Handler() = default;
26 
27  void setFormatter(std::unique_ptr<Formatter> formatter);
28  void setPattern(const std::string& pattern);
29  void format(priv::Message& msg);
30 
31  virtual void flush() = 0;
32  virtual void handle(const priv::Message& msg) = 0;
33 
34  bool shouldLog(Level level) const;
35  void setLevel(Level level);
36  Level getLevel() const;
37 
38 protected:
39  std::string _name;
40  std::unique_ptr<Formatter> _formatter;
42 };
43 
44 template<typename T, typename... Args>
45 T* makeHandler(const std::string& handlerName, Args&&... args);
46 
48 
49 } // Logger
50 } // System
51 } // lug
52 
T * makeHandler(const std::string &handlerName, Args &&... args)
Definition: Handler.inl:2
#define LUG_SYSTEM_API
Definition: Export.hpp:11
std::unique_ptr< Formatter > _formatter
Definition: Handler.hpp:40