flog.appender {futile.logger} | R Documentation |
Manage appenders for loggers
Description
Provides functions for adding and removing appenders.
Arguments
... |
Used internally by lambda.r |
Usage
# Get the appender for the given logger
flog.appender(name) %::% character : Function
flog.appender(name='ROOT')
# Set the appender for the given logger
flog.appender(fn, name='ROOT')
# Print log messages to the console
appender.console()
# Write log messages to a file
appender.file(file)
# Write log messages to console and a file
appender.tee(file)
Details
Appenders do the actual work of writing log messages to some target.
To use an appender in a logger, you must register it to a given logger.
Use flog.appender
to both access and set appenders.
The ROOT logger by default uses appender.console
.
appender.console
is a function that writes to the console.
No additional arguments are necessary when registering the appender
via flog.appender.
appender.file
writes to a file, so you must pass an additional file
argument to the function. To change the file name, just call
flog.appender(appender.file(file))
again with a new file name.
To use your own appender create a function that takes a single argument,
which represents the log message. You need to pass a function reference to
flog.appender
.
appender.tee
writes to both the console and file.
Value
When getting the appender, flog.appender
returns the appender
function. When setting an appender, flog.appender
has no
return value.
Author(s)
Brian Lee Yung Rowe
See Also
Examples
## Not run:
flog.appender(appender.console(), name='my.logger')
# Set an appender to the logger named 'my.package'. Any log operations from
# this package will now use this appender.
flog.appender(appender.file('my.package.out'), 'my.package')
## End(Not run)