Qore Logger Module Reference 0.6
|
Implements appender writing to a file with file rotation support. More...
#include <Logger.qm.dox.h>
Public Member Methods | |
constructor (*string name, LoggerLayout layout, string filename, int count=DEFAULT_ROTATION_COUNT, string archive=DEFAULT_ARCHIVE_PATTERN, *string encoding) | |
Creates the object. More... | |
string | getArchiveFileName (int idx) |
Returns the archive filename. More... | |
int | getCount () |
Returns max.number of files in chain. | |
processEventImpl (int type, auto params) | |
Implements filename rotation; handles the open and rotate events directly. More... | |
abstract int | getCount () |
Abstract method to get count of rotation objects. | |
Public Member Methods inherited from Logger::LoggerAppenderFile | |
constructor (*string name, LoggerLayout layout, string filename, *string encoding) | |
Creates the object. More... | |
File | getFile () |
Returns the file object for the appender. | |
string | getFileName () |
Returns the current filename. | |
processEventImpl (int type, auto params) | |
Processes open, close, and log events with the file and ignores all other events. More... | |
Public Member Methods inherited from Logger::LoggerAppenderWithLayout | |
constructor (*string name, LoggerLayout layout) | |
Creates the object. More... | |
LoggerLayout | getLayout () |
Returns the layout for the appender. | |
setLayout (LoggerLayout layout) | |
Assigns a layout to the appender. More... | |
Public Member Methods inherited from Logger::LoggerAppender | |
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... | |
processEvent (int type, auto params) | |
Processes an event to the physical target. 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 | DEFAULT_ARCHIVE_PATTERN = "%p%f.%i" |
default archive pattern | |
Public Attributes inherited from Logger::AbstractLoggerAppenderFileRotate | |
const | DEFAULT_ROTATION_COUNT = 10 |
default value for rotation chain | |
const | EVENT_ROTATE = 10001 |
rotate event | |
Public Attributes inherited from Logger::LoggerAppenderFile | |
const | DEFAULT_OPEN_FLAGS = O_CREAT | O_APPEND | O_WRONLY |
Default open flags. | |
const | EVENT_REOPEN = 1001 |
reopen event | |
Public Attributes inherited from Logger::LoggerAppender | |
const | EVENT_CLOSE = 3 |
close event | |
const | EVENT_LOG = 2 |
logging event | |
const | EVENT_OPEN = 1 |
open event | |
Private Member Methods | |
*string | resolveField (auto data, string key, *string option) |
Returns a string for a format field for a pattern-based filename. More... | |
Private Member Methods inherited from Logger::LoggerAppenderWithLayout | |
auto | serializeImpl (LoggerEvent event) |
Returns the value formatted using the layout pattern. More... | |
Private Member Methods inherited from Logger::LoggerAppender | |
*object | ensureAtomicOperations (int type) |
Returns an object that can be used to ensure atomic operations for appender operations. | |
RWLock | lock () |
The lock to ensure proper serialization with concurrent access. | |
bool | pushEvent (int type, auto params) |
Pushes the given event on the queue or calls processEvent() 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... | |
abstract *string | resolveField (auto data, string key, *string option) |
Returns a formatted string for an input pattern. More... | |
constructor (string pattern) | |
Creates the object. More... | |
string | format (auto data) |
Formats the event record with the current pattern. More... | |
string | getPattern () |
Returns the current pattern. | |
setPattern (string value) | |
Sets the new pattern. More... | |
Additional Inherited Members | |
Private Attributes inherited from Logger::LoggerPattern | |
list< auto > | parsedPattern |
parsed pattern; list elements may be strings or hashes | |
const | ESCAPE_CHAR = "%" |
format escape character | |
Implements appender writing to a file with file rotation support.
The events will be logged to a file until rotation occurs. At that moment the current file is closed, archive chain is moved, new file is created and logging continues there.
Logger::LoggerAppenderFileRotate::constructor | ( | *string | name, |
LoggerLayout | layout, | ||
string | filename, | ||
int | count = DEFAULT_ROTATION_COUNT , |
||
string | archive = DEFAULT_ARCHIVE_PATTERN , |
||
*string | encoding | ||
) |
Creates the object.
name | the name of the appender |
layout | the layout for the appender |
filename | with pattern support; see below for more information |
count | number of files in rotation chain, if count is <=0 then no ratation is performed |
archive | pattern to evaluate archive filename; see below for more information |
encoding | the encoding of the output file |
The following table explains the characters used in LoggerPattern for both filename and archive parameter
Conversion character | Meaning |
%s | Used to output the OS directory separator, i.e. "\" or "/"</td> </tr> <tr> <td>\c %%c</td> <td>Used to output the appender name</td> </tr> <tr> <td>\c %%C</td> <td>Used to output the appender class name</td> </tr> <tr> <td>\c %%E</td> <td>Used to output the environment variable with name given by option, e.g. \c "E{HOME}"</td> </tr> <tr> <td>\c %%</td> <td>The literal percent sign. \c "%%" will print a \c "%" sign</td> </tr> </table> The following table explains the characters used in @ref LoggerPattern for archive parameter only <table> <tr> <td class="qore"><b>Conversion character</b></td> <td class="qore"><b>Meaning</b></td> </tr> <tr> <td>\c %%P</td> <td>Used to output the current logging path with filename</td> </tr> <tr> <td>\c %%p</td> <td>Used to output the current logging path</td> </tr> <tr> <td>\c %%f</td> <td>Used to output the current logging filename</td> </tr> <tr> <td>\c %%i</td> <td>Used to output the current file index from 1 to count. option may specify @ref Qore::sprintf() "sprintf()"() format, e.g. \c "%.3d"</td> </tr> <tr> <td>\c %%n</td> <td>Used to output the rotation count. Option may specify @ref Qore::sprintf() "sprintf()"() format, e.g. \c "%.3d"</td> </tr> </table> For example, the archive pattern \c "pf.i" rotates log file \c "/var/run/log/MyLogger.log" to: \c "/var/run/log/MyLogger.log.1" \c "/var/run/log/MyLogger.log.2" \c "/var/run/log/MyLogger.log.3". |
string Logger::LoggerAppenderFileRotate::getArchiveFileName | ( | int | idx | ) |
Returns the archive filename.
idx | the index of file (1..count) |
|
virtual |
Implements filename rotation; handles the open and rotate events directly.
All other events are handled by subclasses
type | the event type |
params | event parameters |
Reimplemented from Logger::LoggerAppenderFile.
|
privatevirtual |
Returns a string for a format field for a pattern-based filename.
data | input context reference data |
key | the format character |
option | the format option value, if any |
Implements Logger::LoggerPattern.