Learn R Programming

futile.logger (version 1.2.1)

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

Description

Provides functions for managing loggers. The 'getLogger' function is the primary entry point into the package once the configuration is complete.

Usage

addLogger(name, threshold, appender, layout)
getLogger(name = 'ROOT', failfast = FALSE)
loggerAppender(name)
loggerThreshold(name)

Arguments

name
The name of the logger
threshold
The logger threshold, which can be partially overridden by appenders. Use one of the constants defined (e.g. DEBUG, INFO, WARN, etc)
appender
An appender name or a vector of appender names
layout
A layout name or a vector of layout names
failfast
Used internally to prevent inheritance of loggers

Value

  • 'getLogger' returns a _function_ that is called to log messages. The resulting function has two arguments: the log level for the message and the message itself. The below example illustrates the simplest usage pattern:

    > lg <- getLogger() > lg(DEBUG, "A debug message")

    Typically, the built in log level constants are used in the call, which conform to the log4j levels (from least severe to most severe): TRACE, DEBUG, INFO, WARN, ERROR, FATAL. It is not a strict requirement to use these constants (any numeric value will work), though most users should find this level of granularity sufficient.

    Loggers are hierarchical in the sense that any requested logger that is undefined will fall back to its most immediate defined parent logger. The absolute parent is ROOT, which _must_ be defined for the system to work.

Details

'addLogger' adds a logger configuration to the logger.options

'getLogger' constructs a logger function based on the registered configuration

'loggerAppender' provides introspection on the appenders attached to a logger

'loggerThreshold' provides the threshold of the logger

Examples

Run this code
lg <- getLogger("some.package")
  lg(DEBUG, "A debug message")

Run the code above in your browser using DataLab