Qore Logger Module Reference 1.0
|
Implements appender writing to a file with archive support. More...
#include <Logger.qm.dox.h>
Inherits LoggerAppenderFile, and LoggerPattern.
Public Member Methods | |
string | archive () |
Posts an archive event. More... | |
constructor (*string name, LoggerLayout layout, string filename, string archive=DEFAULT_ARCHIVE_PATTERN, *string encoding) | |
Creates the object. More... | |
string | getArchiveFileName () |
Returns the archive filename. More... | |
processEventImpl (int type, auto params) | |
Implements archiving, handles the archive event directly, passes all other events to the subclass for handling. More... | |
Public Attributes | |
const | DEFAULT_ARCHIVE_PATTERN = "%p%f.%d" |
default archive pattern | |
const | DEFAULT_DATE_FORMAT = "YYYYMMDDHHmmSS" |
default date format | |
const | EVENT_ARCHIVE = 20 |
archive event | |
Private Member Methods | |
*string | resolveField (auto data, string key, *string option) |
Returns a string for a format field for a pattern-based filename or archive file name. More... | |
Implements appender writing to a file with archive support.
The events will be logged to a file until archiving is triggered. At that moment the current file is closed, moved to file with name evaluated in runtime from the archive pattern set in the object, the new file is created, and logging continues to that file. The archive never overwrites any existing file.
string Logger::LoggerAppenderFileArchive::archive | ( | ) |
Posts an archive event.
rename logging file and open new one
LOGGER-ERROR | if target file name is not correct or target file already exists |
Logger::LoggerAppenderFileArchive::constructor | ( | *string | name, |
LoggerLayout | layout, | ||
string | filename, | ||
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 |
archive | pattern to evaluate archive filename; see below for more information |
encoding | the output file's encoding |
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 Qore::Logger::LoggerPattern "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 %%d</td> <td>Used to output the date of the logging event using @ref Qore::format_date() "format_date()". Option may specify date \</td> </tr> </table> format, e.g. \c "d{DD.MM.YYYY HH:mm:SS}", default value is \c "YYYYMMDDHHmmSS" | For example, the archive pattern \c "p/archive/d/f" archives log file \c "/var/run/log/MyLogger.log" to: \c "/var/run/log/archive/20180120102030/MyLogger.log". |
string Logger::LoggerAppenderFileArchive::getArchiveFileName | ( | ) |
Returns the archive filename.
The pattern may contain date fields so the result may differ when executed multiple times
Logger::LoggerAppenderFileArchive::processEventImpl | ( | int | type, |
auto | params | ||
) |
Implements archiving, handles the archive event directly, passes all other events to the subclass for handling.
type | the event code |
params | event parameters |
|
private |
Returns a string for a format field for a pattern-based filename or archive file name.
data | if NOTHING, then this argument specifies the logging filename, otherwise is specifies the archive pattern |
key | the format character |
option | the format option value, if any |