CppLogging  1.0.4.0
C++ Logging Library
buffered_processor.h
Go to the documentation of this file.
1 
9 #ifndef CPPLOGGING_PROCESSORS_BUFFERED_PROCESSOR_H
10 #define CPPLOGGING_PROCESSORS_BUFFERED_PROCESSOR_H
11 
12 #include "logging/processor.h"
13 
14 namespace CppLogging {
15 
17 
29 {
30 public:
32 
37  explicit BufferedProcessor(const std::shared_ptr<Layout>& layout, size_t limit = 65536, size_t capacity = 8192) : Processor(layout), _limit(limit)
38  { _buffer.reserve(capacity); }
41  virtual ~BufferedProcessor() = default;
42 
45 
46  // Implementation of Processor
47  bool ProcessRecord(Record& record) override;
48  void Flush() override;
49 
50 private:
51  size_t _limit;
52  std::vector<Record> _buffer;
53 
54  void ProcessBufferedRecords();
55 };
56 
57 } // namespace CppLogging
58 
59 #endif // CPPLOGGING_PROCESSORS_BUFFERED_PROCESSOR_H
Buffered logging processor.
bool ProcessRecord(Record &record) override
Process the given logging record through all child filters, layouts and appenders.
BufferedProcessor(const std::shared_ptr< Layout > &layout, size_t limit=65536, size_t capacity=8192)
Initialize buffered processor with a given layout interface, limit and capacity.
virtual ~BufferedProcessor()=default
BufferedProcessor(BufferedProcessor &&)=delete
BufferedProcessor & operator=(const BufferedProcessor &)=delete
void Flush() override
Flush the current logging processor.
BufferedProcessor & operator=(BufferedProcessor &&)=delete
BufferedProcessor(const BufferedProcessor &)=delete
Logging processor interface.
Definition: processor.h:31
std::shared_ptr< Layout > & layout() noexcept
Get the logging processor layout.
Definition: processor.h:46
Logging record.
Definition: record.h:37
C++ Logging project definitions.
Definition: appender.h:15
Logging processor interface definition.