Logger::LoggerAppenderFileRotate Class Reference

Implements appender writing to a file with file rotation support. More...

Inheritance diagram for Logger::LoggerAppenderFileRotate:
[legend]

## Public Member Functions

| constructor (*string n_name, LoggerLayout n_layout, string n_filename, int n_count=DEFAULT_ROTATION_COUNT, string n_archive=DEFAULT_ARCHIVE_PATTERN, *string n_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; passes all other events to the subclass for handling. More...
Public Member Functions inherited from Logger::AbstractLoggerAppenderFileRotate
| rotate ()
| Pushes rotate event. More...
Public Member Functions inherited from Logger::LoggerAppenderFile
| constructor (*string n_name, LoggerLayout n_layout, string n_filename, *string n_encoding)
| Creates the object. More...
File | getFile ()
| Returns the file object for the appender.
string | getFileName ()
| Returns the current filename.
Public Member Functions inherited from Logger::LoggerAppenderWithLayout
| constructor (*string n_name, LoggerLayout n_layout)
| Creates the object. More...
LoggerLayout | getLayout ()
| Returns the layout for the appender.
| setLayout (LoggerLayout n_layout)
| Assigns a layout to the appender. More...
Public Member Functions 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 n_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...
| removeAllFilters ()
| Clears the filter chain by removing all filters.
| removeFilter (LoggerFilter filter)
| Removes the given filter from the filter chain. More...
| setQueue (*LoggerAppenderQueue n_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::LoggerAppender
const | EVENT_CLOSE = 3
| close event
const | EVENT_LOG = 2
| logging event
const | EVENT_OPEN = 1
| open event

## Protected Member Functions

*string | resolveField (auto data, string key, *string option)
| Returns a string for a format field for a pattern-based filename. More...
Protected Member Functions inherited from Logger::LoggerAppenderWithLayout
auto | serializeImpl (LoggerEvent event)
| Returns the value formatted using the layout pattern. More...
Protected Member Functions inherited from Logger::LoggerAppender
bool | pushEvent (int type, auto params)
| Pushes the given event on the queue or calls processEventImpl() in case of synchronous processing. 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

Protected Attributes inherited from Logger::LoggerPattern
list | parsedPattern
| parsed pattern
const | ESCAPE_CHAR = "%"
| format escape character

## Detailed Description

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.

## Member Function Documentation

## constructor()

Logger::LoggerAppenderFileRotate::constructor | ( | *string | n_name,
|  | LoggerLayout | n_layout,
|  | string | n_filename,
|  | int | n_count = `DEFAULT_ROTATION_COUNT`,
|  | string | n_archive = `DEFAULT_ARCHIVE_PATTERN`,
|  | *string | n_encoding
| ) |  |

Creates the object.

Parameters

  n_name | the name of the appender
  n_layout | the layout for the appender
  n_filename | with pattern support; see below for more information
  n_count | number of files in rotation chain, if count is <=0 then no ratation is performed
  n_archive | pattern to evaluate archive filename; see below for more information
  n_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 "/"
c | Used to output the appender name
C | Used to output the appender class name
E | Used to output the environment variable with name given by option, e.g. `"%E{HOME}"`
% | The literal percent sign. `"%%"` will print a `"%"` sign

The following table explains the characters used in LoggerPattern for archive parameter only

Conversion character | Meaning
P | Used to output the current logging path with filename
p | Used to output the current logging path
f | Used to output the current logging filename
i | Used to output the current file index from 1 to count. option may specify sprintf() format, e.g. `"%.3d"`
n | Used to output the rotation count. Option may specify sprintf() format, e.g. `"%.3d"`

For example, the archive pattern `"%p%f.%i"` rotates log file `"/var/run/log/MyLogger.log"` to: `"/var/run/log/MyLogger.log.1"` `"/var/run/log/MyLogger.log.2"` `"/var/run/log/MyLogger.log.3"`.

## getArchiveFileName()

string Logger::LoggerAppenderFileRotate::getArchiveFileName | ( | int | idx | ) |

Returns the archive filename.

Parameters

  idx | the index of file (1..count)

## processEventImpl()

Logger::LoggerAppenderFileRotate::processEventImpl | ( | int | type,
|  | auto | params
| ) |  |

virtual

Implements filename rotation; handles the open and rotate events directly; passes all other events to the subclass for handling.

Parameters

  type | the event type
  params | event parameters

Reimplemented from Logger::LoggerAppenderFile.

## resolveField()

*string Logger::LoggerAppenderFileRotate::resolveField | ( | auto | data,
|  | string | key,
|  | *string | option
| ) |  |

protectedvirtual

Returns a string for a format field for a pattern-based filename.

Parameters

  data | input context reference data
  key | the format character
  option | the format option value, if any

Returns
  the formatted string

Implements Logger::LoggerPattern.