CppLogging  1.0.4.0
C++ Logging Library
processor.h
Go to the documentation of this file.
1 
9 #ifndef CPPLOGGING_PROCESSOR_H
10 #define CPPLOGGING_PROCESSOR_H
11 
12 #include "logging/appenders.h"
13 #include "logging/filters.h"
14 #include "logging/layouts.h"
15 
16 namespace CppLogging {
17 
19 
30 class Processor : public Element
31 {
32 public:
34 
37  explicit Processor(const std::shared_ptr<Layout>& layout) : _layout(layout) {}
38  Processor(const Processor&) = delete;
39  Processor(Processor&&) noexcept = delete;
40  virtual ~Processor();
41 
42  Processor& operator=(const Processor&) = delete;
43  Processor& operator=(Processor&&) noexcept = delete;
44 
46  std::shared_ptr<Layout>& layout() noexcept { return _layout; }
48  std::vector<std::shared_ptr<Filter>>& filters() noexcept { return _filters; }
50  std::vector<std::shared_ptr<Appender>>& appenders() noexcept { return _appenders; }
52  std::vector<std::shared_ptr<Processor>>& processors() noexcept { return _processors; }
53 
55  bool IsStarted() const noexcept override { return _started; }
56 
58 
61  bool Start() override;
63 
66  bool Stop() override;
67 
69 
73  virtual bool FilterRecord(Record& record);
74 
76 
87  virtual bool ProcessRecord(Record& record);
88 
90 
95  virtual void Flush();
96 
97 protected:
98  std::atomic<bool> _started{true};
99  std::shared_ptr<Layout> _layout;
100  std::vector<std::shared_ptr<Filter>> _filters;
101  std::vector<std::shared_ptr<Appender>> _appenders;
102  std::vector<std::shared_ptr<Processor>> _processors;
103 };
104 
105 } // namespace CppLogging
106 
107 #endif // CPPLOGGING_PROCESSOR_H
Logging appenders definition.
Logging element interface.
Definition: element.h:26
Logging layout interface.
Definition: layout.h:28
Logging processor interface.
Definition: processor.h:31
std::vector< std::shared_ptr< Appender > > _appenders
Definition: processor.h:101
Processor(const std::shared_ptr< Layout > &layout)
Initialize logging processor with a given layout interface.
Definition: processor.h:37
std::shared_ptr< Layout > _layout
Definition: processor.h:99
bool IsStarted() const noexcept override
Is the logging processor started?
Definition: processor.h:55
bool Stop() override
Stop the logging processor.
Definition: processor.cpp:60
Processor(Processor &&) noexcept=delete
virtual bool ProcessRecord(Record &record)
Process the given logging record through all child filters, layouts and appenders.
Definition: processor.cpp:100
bool Start() override
Start the logging processor.
Definition: processor.cpp:30
std::atomic< bool > _started
Definition: processor.h:98
std::vector< std::shared_ptr< Filter > > _filters
Definition: processor.h:100
std::vector< std::shared_ptr< Processor > > & processors() noexcept
Get collection of child processors.
Definition: processor.h:52
std::vector< std::shared_ptr< Processor > > _processors
Definition: processor.h:102
virtual void Flush()
Flush the current logging processor.
Definition: processor.cpp:127
Processor(const Processor &)=delete
std::vector< std::shared_ptr< Filter > > & filters() noexcept
Get collection of child filters.
Definition: processor.h:48
std::shared_ptr< Layout > & layout() noexcept
Get the logging processor layout.
Definition: processor.h:46
std::vector< std::shared_ptr< Appender > > & appenders() noexcept
Get collection of child appenders.
Definition: processor.h:50
virtual bool FilterRecord(Record &record)
Filter the given logging record.
Definition: processor.cpp:90
Logging record.
Definition: record.h:37
Logging filters definition.
Logging layouts definition.
C++ Logging project definitions.
Definition: appender.h:15