Learn R Programming

futile.logger (version 1.2.1)

addAppender: Manage appenders within the 'futile.logger' sub-system

Description

Provides functions for managing appenders. Typically only addAppender is used when manually creating a logging configuration.

Usage

getAppender(name)
## S3 method for class 'default':
addAppender(name, ..., threshold = NULL)
## S3 method for class 'character':
addAppender(name, fun, ..., threshold = NULL)

Arguments

name
The name of the appender or the appender itself. If the appender function is passed as the name, the symbol will be used as the name
threshold
The threshold at which the appender is activated
fun
The appender function, which must be passed explicitly if the name of the appender is different from the appender function's symbol
...
Further arguments to pass to the appender function when it is activated

Value

  • 'getAppender' returns an appender function, which is wrapped in a parent function to enforce a consistent calling API.

Details

Appenders do the actual work of writing log messages to some target. To use an appender in a logger, it must first be added to the system via the 'addAppender' call. Once the appender has been registered, loggers can reference the appender and call it to log messages.

The 'getAppender' function is used internally to get the registered appender function. It is kept visible so user-level introspection is available.

'consoleAppender' is a function that writes to the console. No additional arguments are necessary when registering the appender via addAppender.

'fileAppender is an appender that writes to a file. An additional file argument must be passed to addAppender when registering a fileAppender.

Examples

Run this code
addAppender('file1', fileAppender, file='file1.log')
  addAppender('file2', fileAppender, file='file2.log', threshold=WARN)
  addAppender(consoleAppender, threshold=INFO)

Run the code above in your browser using DataLab