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

Asynchronous wait-free logging processor. More...

#include <async_wait_free_processor.h>

Inheritance diagram for CppLogging::AsyncWaitFreeProcessor:
CppLogging::Processor CppLogging::Element

Public Member Functions

 AsyncWaitFreeProcessor (const std::shared_ptr< Layout > &layout, bool auto_start=true, size_t capacity=8192, bool discard=false, const std::function< void()> &on_thread_initialize=[](){}, const std::function< void()> &on_thread_clenup=[](){})
 Initialize asynchronous processor with a given layout interface, overflow policy and buffer capacity. More...
 
 AsyncWaitFreeProcessor (const AsyncWaitFreeProcessor &)=delete
 
 AsyncWaitFreeProcessor (AsyncWaitFreeProcessor &&)=delete
 
virtual ~AsyncWaitFreeProcessor ()
 
AsyncWaitFreeProcessoroperator= (const AsyncWaitFreeProcessor &)=delete
 
AsyncWaitFreeProcessoroperator= (AsyncWaitFreeProcessor &&)=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-free logging processor.

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

This processor use fixed size async buffer which can overflow.

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

Thread-safe.

Definition at line 33 of file async_wait_free_processor.h.

Constructor & Destructor Documentation

◆ AsyncWaitFreeProcessor() [1/3]

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

Initialize asynchronous processor with a given layout interface, overflow policy and buffer capacity.

Parameters
layout- Logging layout interface
auto_start- Auto-start the logging processor (default is true)
capacity- Buffer capacity in logging records (default is 8192)
discard- Discard logging records on buffer overflow or block and wait (default is false)
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_free_processor.cpp.

◆ AsyncWaitFreeProcessor() [2/3]

CppLogging::AsyncWaitFreeProcessor::AsyncWaitFreeProcessor ( const AsyncWaitFreeProcessor )
delete

◆ AsyncWaitFreeProcessor() [3/3]

CppLogging::AsyncWaitFreeProcessor::AsyncWaitFreeProcessor ( AsyncWaitFreeProcessor &&  )
delete

◆ ~AsyncWaitFreeProcessor()

CppLogging::AsyncWaitFreeProcessor::~AsyncWaitFreeProcessor ( )
virtual

Definition at line 32 of file async_wait_free_processor.cpp.

Member Function Documentation

◆ Flush()

void CppLogging::AsyncWaitFreeProcessor::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 177 of file async_wait_free_processor.cpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ ProcessRecord()

bool CppLogging::AsyncWaitFreeProcessor::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 73 of file async_wait_free_processor.cpp.

◆ Start()

bool CppLogging::AsyncWaitFreeProcessor::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 39 of file async_wait_free_processor.cpp.

◆ Stop()

bool CppLogging::AsyncWaitFreeProcessor::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 55 of file async_wait_free_processor.cpp.


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