Qore logger_bin Module 2.1.1
Loading...
Searching...
No Matches
Qore::Logger::LoggerAppender Class Reference

Abstract class that defines the interface for logger appenders. More...

#include <QC_LoggerAppender.dox.h>

Inheritance diagram for Qore::Logger::LoggerAppender:
Qore::Logger::LoggerAppenderWithLayout Qore::Logger::LoggerAppenderFile

Public Member Methods

 addFilter (LoggerFilter filter, bool top=False)
 Adds a filter to the chain.
 
 close ()
 Releases any resources allocated by the appender and closes it.
 
 constructor ()
 Creates the object.
 
 constructor (string name)
 Creates the object.
 
list< LoggerFiltergetFilters ()
 Returns the filter chain as a list.
 
string getName ()
 Returns the appender name.
 
*LoggerAppenderQueue getQueue ()
 Returns async queue or nothing when events are processed synchronously.
 
bool isOpen ()
 Returns True if the appender is open and therefore active.
 
 open ()
 Opens logging resources.
 
bool post (LoggerEvent event)
 Posts the given event to the output queue.
 
 processEvent (int type, auto params)
 Processes an event to the physical target.
 
abstract processEventImpl (int type, auto params)
 Processes the event to the physical target.
 
 removeAllFilters ()
 Clears the filter chain by removing all filters.
 
 removeFilter (LoggerFilter filter)
 Removes the given filter from the filter chain.
 
 setQueue (*LoggerAppenderQueue queue)
 Sets the appender queue.
 

Private Member Methods

*object ensureAtomicOperations (int type)
 Returns an object that can be used to ensure atomic operations for appender operations.
 
bool pushEvent (int type, auto params)
 Pushes the given event on the queue or calls processEvent() in case of synchronous processing.
 
abstract auto serializeImpl (LoggerEvent event)
 Serializes the given event to put in the queue or write to the target device.
 

Detailed Description

Abstract class that defines the interface for logger appenders.

Event data (LoggerEvent) are formatted before the record is passed to the target

Member Function Documentation

◆ addFilter()

Qore::Logger::LoggerAppender::addFilter ( LoggerFilter  filter,
bool  top = False 
)

Adds a filter to the chain.

Parameters
filterthe new filter to add
topif True then the filter is added at the start of the filter chain, if False (the default), the filter is added at the end of the chain
Exceptions
LOGGER-ERRORthrown if the filter is already in the list

◆ constructor()

Qore::Logger::LoggerAppender::constructor ( string  name)

Creates the object.

Parameters
namethe appender name

◆ getFilters()

list< LoggerFilter > Qore::Logger::LoggerAppender::getFilters ( )

Returns the filter chain as a list.

Note that appender filter chain may be modified as internal lock is released when copy of list is returned

◆ open()

Qore::Logger::LoggerAppender::open ( )

Opens logging resources.

The appender must be opened to accept any logging events

◆ post()

bool Qore::Logger::LoggerAppender::post ( LoggerEvent  event)

Posts the given event to the output queue.

Invokes filters; when the event is accepted then it is posted to the queue in case of asynchronous processing, or it is immediately logged by the processEvent() method in case of synchronous processing.

See also
processEvent()
Parameters
eventthe event to post
Returns
True if the event has been posted, False if not (filtered out, appender inactive, event not accepted on queue, etc)

◆ processEvent()

Qore::Logger::LoggerAppender::processEvent ( int  type,
auto  params 
)

Processes an event to the physical target.

See also
serializeImpl()
Parameters
typesee "EVENT_xxx" constants
paramsprocessing parameters

◆ processEventImpl()

abstract Qore::Logger::LoggerAppender::processEventImpl ( int  type,
auto  params 
)

Processes the event to the physical target.

Must be implemented by non-abstract subclasses

See also
serializeImpl()
Parameters
typesee "EVENT_xxx" constants
paramsprocessing parameters

◆ pushEvent()

bool Qore::Logger::LoggerAppender::pushEvent ( int  type,
auto  params 
)
private

Pushes the given event on the queue or calls processEvent() in case of synchronous processing.

Parameters
typethe event type
paramsparameters for the event according to the event type
Returns
True if the event was accepted/processed, False if not
See also
processEvent()

◆ removeFilter()

Qore::Logger::LoggerAppender::removeFilter ( LoggerFilter  filter)

Removes the given filter from the filter chain.

Parameters
filterthe filter to remove

◆ serializeImpl()

abstract auto Qore::Logger::LoggerAppender::serializeImpl ( LoggerEvent  event)
private

Serializes the given event to put in the queue or write to the target device.

The appender implementaion can define any format for serialization. The data are passed to processEvent() method in the params argument when type is EVENT_LOG.

Returns
the serialized event

◆ setQueue()

Qore::Logger::LoggerAppender::setQueue ( *LoggerAppenderQueue  queue)

Sets the appender queue.

Data are passed to target device synchronously unless queue is assigned. In this case data are queued and dedicated process will process it asynchronously

Parameters
queuethe queue to set
Exceptions
LOGGER-ERRORthrown if appender is opened

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