CppLogging  1.0.4.0
C++ Logging Library
Public Member Functions | List of all members
CppLogging::AsyncWaitProcessor Class Reference

Asynchronous wait logging processor. More...

#include <async_wait_processor.h>

Inheritance diagram for CppLogging::AsyncWaitProcessor:
CppLogging::Processor CppLogging::Element

Public Member Functions

 AsyncWaitProcessor (const std::shared_ptr< Layout > &layout, bool auto_start=true, size_t capacity=8192, size_t initial=8192, const std::function< void()> &on_thread_initialize=[](){}, const std::function< void()> &on_thread_clenup=[](){})
 Initialize asynchronous processor with a given layout interface. More...
 
 AsyncWaitProcessor (const AsyncWaitProcessor &)=delete
 
 AsyncWaitProcessor (AsyncWaitProcessor &&)=delete
 
virtual ~AsyncWaitProcessor ()
 
AsyncWaitProcessoroperator= (const AsyncWaitProcessor &)=delete
 
AsyncWaitProcessoroperator= (AsyncWaitProcessor &&)=delete
 
bool Start () override
 Start the logging processor. More...
 
bool Stop () override
 Stop the logging processor. More...
 
bool ProcessRecord (Record &record) override
 Process the given logging record through all child filters, layouts and appenders. More...
 
void Flush () override
 Flush the current logging processor. More...
 
- Public Member Functions inherited from CppLogging::Processor
 Processor (const std::shared_ptr< Layout > &layout)
 Initialize logging processor with a given layout interface. More...
 
 Processor (const Processor &)=delete
 
 Processor (Processor &&) noexcept=delete
 
virtual ~Processor ()
 
Processoroperator= (const Processor &)=delete
 
Processoroperator= (Processor &&) noexcept=delete
 
std::shared_ptr< Layout > & layout () noexcept
 Get the logging processor layout. More...
 
std::vector< std::shared_ptr< Filter > > & filters () noexcept
 Get collection of child filters. More...
 
std::vector< std::shared_ptr< Appender > > & appenders () noexcept
 Get collection of child appenders. More...
 
std::vector< std::shared_ptr< Processor > > & processors () noexcept
 Get collection of child processors. More...
 
bool IsStarted () const noexcept override
 Is the logging processor started? More...
 
virtual bool FilterRecord (Record &record)
 Filter the given logging record. More...
 

Additional Inherited Members

- Protected Attributes inherited from CppLogging::Processor
std::atomic< bool > _started {true}
 
std::shared_ptr< Layout_layout
 
std::vector< std::shared_ptr< Filter > > _filters
 
std::vector< std::shared_ptr< Appender > > _appenders
 
std::vector< std::shared_ptr< Processor > > _processors
 

Detailed Description

Asynchronous wait logging processor.

Asynchronous wait logging processor stores the given logging record into thread-safe buffer and process it in the separate thread.

This processor use dynamic size async buffer which cannot overflow, buy might lead to out of memory error.

Please note that asynchronous logging processor moves the given logging record (ProcessRecord() method always returns false) into the buffer!

Thread-safe.

Definition at line 35 of file async_wait_processor.h.

Constructor & Destructor Documentation

◆ AsyncWaitProcessor() [1/3]

CppLogging::AsyncWaitProcessor::AsyncWaitProcessor ( const std::shared_ptr< Layout > &  layout,
bool  auto_start = true,
size_t  capacity = 8192,
size_t  initial = 8192,
const std::function< void()> &  on_thread_initialize = [](){},
const std::function< void()> &  on_thread_clenup = [](){} 
)
explicit

Initialize asynchronous processor with a given layout interface.

Parameters
layout- Logging layout interface
auto_start- Auto-start the logging processor (default is true)
capacity- Buffer capacity in logging records (0 for unlimited capacity, default is 8192)
initial- Buffer initial capacity in logging records (default is 8192)
on_thread_initialize- Thread initialize handler can be used to initialize priority or affinity of the logging thread (default does nothing)
on_thread_clenup- Thread cleanup handler can be used to cleanup priority or affinity of the logging thread (default does nothing)

Definition at line 18 of file async_wait_processor.cpp.

◆ AsyncWaitProcessor() [2/3]

CppLogging::AsyncWaitProcessor::AsyncWaitProcessor ( const AsyncWaitProcessor )
delete

◆ AsyncWaitProcessor() [3/3]

CppLogging::AsyncWaitProcessor::AsyncWaitProcessor ( AsyncWaitProcessor &&  )
delete

◆ ~AsyncWaitProcessor()

CppLogging::AsyncWaitProcessor::~AsyncWaitProcessor ( )
virtual

Definition at line 31 of file async_wait_processor.cpp.

Member Function Documentation

◆ Flush()

void CppLogging::AsyncWaitProcessor::Flush ( )
overridevirtual

Flush the current logging processor.

Default behavior of the method will flush in the following sequence:

  • all appenders (if any present)
  • all sub processors (if any present)

Reimplemented from CppLogging::Processor.

Definition at line 162 of file async_wait_processor.cpp.

◆ operator=() [1/2]

AsyncWaitProcessor& CppLogging::AsyncWaitProcessor::operator= ( AsyncWaitProcessor &&  )
delete

◆ operator=() [2/2]

AsyncWaitProcessor& CppLogging::AsyncWaitProcessor::operator= ( const AsyncWaitProcessor )
delete

◆ ProcessRecord()

bool CppLogging::AsyncWaitProcessor::ProcessRecord ( Record record)
overridevirtual

Process the given logging record through all child filters, layouts and appenders.

Default behavior of the method will take the given logging record and process it in the following sequence:

  • all filters (if any present)
  • all layouts (if any present)
  • all appenders (if any present)
  • all sub processors (if any present)
Parameters
record- Logging record
Returns
'true' if the logging record was successfully processed, 'false' if the logging record was filtered out

Reimplemented from CppLogging::Processor.

Definition at line 72 of file async_wait_processor.cpp.

◆ Start()

bool CppLogging::AsyncWaitProcessor::Start ( )
overridevirtual

Start the logging processor.

Returns
'true' if the logging processor was successfully started, 'false' if the logging processor failed to start

Reimplemented from CppLogging::Processor.

Definition at line 38 of file async_wait_processor.cpp.

◆ Stop()

bool CppLogging::AsyncWaitProcessor::Stop ( )
overridevirtual

Stop the logging processor.

Returns
'true' if the logging processor was successfully stopped, 'false' if the logging processor failed to stop

Reimplemented from CppLogging::Processor.

Definition at line 54 of file async_wait_processor.cpp.


The documentation for this class was generated from the following files: