CppLogging  1.0.4.0
C++ Logging Library
buffered_processor.cpp
Go to the documentation of this file.
1 
10 
11 namespace CppLogging {
12 
14 {
15  // Check if the logging processor started
16  if (!IsStarted())
17  return true;
18 
19  // Process all buffered logging records if the buffer limit is reached
20  if ((_buffer.size() + 1) > _limit)
21  ProcessBufferedRecords();
22 
23  // Move the given logging record into the buffer
24  _buffer.emplace_back(std::move(record));
25 
26  // Always return false to stop further logging record processing
27  return false;
28 }
29 
30 void BufferedProcessor::ProcessBufferedRecords()
31 {
32  // Process all buffered logging records
33  for (auto& record : _buffer)
35 
36  // Clear buffer
37  _buffer.clear();
38 }
39 
41 {
42  // Check if the logging processor started
43  if (!IsStarted())
44  return;
45 
46  // Process all buffered logging records
47  ProcessBufferedRecords();
48 
49  // Flush the logging processor
51 }
52 
53 } // namespace CppLogging
Buffered logging processor definition.
bool ProcessRecord(Record &record) override
Process the given logging record through all child filters, layouts and appenders.
void Flush() override
Flush the current logging processor.
bool IsStarted() const noexcept override
Is the logging processor started?
Definition: processor.h:55
virtual bool ProcessRecord(Record &record)
Process the given logging record through all child filters, layouts and appenders.
Definition: processor.cpp:100
virtual void Flush()
Flush the current logging processor.
Definition: processor.cpp:127
Logging record.
Definition: record.h:37
C++ Logging project definitions.
Definition: appender.h:15