Qore Logger Module Reference
0.2
|
Implements passing LoggerEvent to target destination. More...
Public Member Methods | |
addFilter (LoggerFilter filter, bool top=False) | |
Adds a filter to the chain. More... | |
close () | |
Releases any resources allocated by the appender and closes it. | |
constructor (*string name) | |
Creates the object. More... | |
list< LoggerFilter > | getFilters () |
Returns the filter chain as a list. More... | |
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. More... | |
bool | post (LoggerEvent event) |
Posts the given event to the output queue. More... | |
abstract | processEventImpl (int type, auto params) |
Processes the event to the physical target. More... | |
removeAllFilters () | |
Clears the filter chain by removing all filters. | |
removeFilter (LoggerFilter filter) | |
Removes the given filter from the filter chain. More... | |
setQueue (*LoggerAppenderQueue queue) | |
Sets the appender queue. More... | |
Public Attributes | |
const | EVENT_CLOSE = 3 |
close event | |
const | EVENT_LOG = 2 |
logging event | |
const | EVENT_OPEN = 1 |
open event | |
Private Member Methods | |
bool | pushEvent (int type, auto params) |
Pushes the given event on the queue or calls processEventImpl() in case of synchronous processing. More... | |
abstract auto | serializeImpl (LoggerEvent event) |
Serializes the given event to put in the queue or write to the target device. More... | |
Private:Internal Member Methods | |
RWLock | lock () |
The lock to ensure proper serialization with concurrent access. | |
Private:Internal Attributes | |
bool | active = False |
An inactive appender won't accept any logging request. | |
list< LoggerFilter > | filters |
filter chain | |
string | name |
Appender name. | |
*LoggerAppenderQueue | queue |
async queue | |
Implements passing LoggerEvent to target destination.
subclasses will implement e.g. logging to file, to stderr, to database etc. LoggerAppender
supports sync and async logging.
The ability to selectively enable or disable logging requests based on level in Logger is extended in the appender via LoggerFilter, which implements filtering on any criteria.
The appender instance should be closed via close() method explicitely to stop accepting logging events which might arrive later than destructing process has started. This process cannot start by design before all events has been processed as the LoggerEvent instance holds refeence to this appender instance.
Logger::LoggerAppender::addFilter | ( | LoggerFilter | filter, |
bool | top = False |
||
) |
Logger::LoggerAppender::constructor | ( | *string | name | ) |
Creates the object.
name | the appender name |
list<LoggerFilter> 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
Logger::LoggerAppender::open | ( | ) |
Opens logging resources.
The appender must be opened to accept any logging events
bool 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 processEventImpl() method in case of synchronous processing.
event | the event to post |
|
pure virtual |
Processes the event to the physical target.
Must be implemented by non-abstract subclasses
type | see "EVENT_xxx" constants |
params | processing parameters |
Implemented in Logger::LoggerAppenderFileArchive, Logger::LoggerAppenderFileRing, Logger::LoggerAppenderFileRotate, Logger::LoggerAppenderStdErr, Logger::LoggerAppenderStdOut, Logger::LoggerAppenderFile, Logger::LoggerAppenderStream, and Logger::LoggerAppenderNull.
|
private |
Pushes the given event on the queue or calls processEventImpl() in case of synchronous processing.
type | the event type |
params | parameters for the event according to the event type |
Logger::LoggerAppender::removeFilter | ( | LoggerFilter | filter | ) |
Removes the given filter from the filter chain.
filter | the filter to remove |
|
privatepure virtual |
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 processEventImpl() method in the params
argument when type
is EVENT_LOG
.
Implemented in Logger::LoggerAppenderWithLayout, and Logger::LoggerAppenderNull.
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
queue |
LOGGER-ERROR | thrown if appender is opened |