Layouts are responsible for formatting messages. This operation usually consists of adding the log level, a timestamp, plus some pretty-printing to make the log messages easy on the eyes.
An important part of loggers is that they are hierarchical in nature based on the namespace given to the logger, such that loggers will inherit properties of parent loggers up to the ROOT if no definition is found. In practice packages can define a logger hierarchy that will work in user libraries, assuming the ROOT logger is configured properly.
To use 'futile.logger', at a minimum, one layout, appender, and logger (ROOT) must be defined. A number of default configurations are provided in the package to get users started quickly, while also acting as examples for users needing more sophisticated logging.
config_logger
, addAppender
,
addLayout
, addLogger
, getLogger
config_logger()
mylogger <- getLogger()
mylogger(DEBUG, "This won't print")
mylogger(WARN, "This will print")
logger.b <- getLogger('b')
logger.b(WARN, "This inherits from the ROOT logger")
Run the code above in your browser using DataLab