Description Arguments Usage Details Author(s) See Also Examples
Provides functions for managing layouts. Typically 'flog.layout' is only used when manually creating a logging configuration.
... |
Used internally by lambda.r |
# Get the layout function for the given logger
flog.layout(name) %::% character : Function
flog.layout(name='ROOT')
# Set the layout function for the given logger
flog.layout(fn, name='ROOT')
# Decorate log messages with a standard format
layout.simple(level, msg, ...)
# Generate log messages as JSON
layout.json(level, msg, ...)
# Decorate log messages using a custom format
layout.format(format, datetime.fmt="
# Show the value of a single variable layout.tracearg(level, msg, ...)
Layouts are responsible for formatting messages so they are human-readable.
Similar to an appender, a layout is assigned to a logger by calling
flog.layout
. The flog.layout
function is used internally
to get the registered layout function. It is kept visible so
user-level introspection is possible.
layout.simple
is a pre-defined layout function that
prints messages in the following format:
LEVEL [timestamp] message
This is the default layout for the ROOT logger.
layout.format
allows you to specify the format string to use
in printing a message. The following tokens are available.
Log level
Timestamp
Namespace
The calling function
The message
layout.json
converts the message and any additional objects provided
to a JSON structure. E.g.:
flog.info("Hello, world", cat='asdf')
yields something like
{"level":"INFO","timestamp":"2015-03-06 19:16:02 EST","message":"Hello, world","func":"(shell)","cat":["asdf"]}
layout.tracearg
is a special layout that takes a variable
and prints its name and contents.
Brian Lee Yung Rowe
1 2 3 4 5 6 7 8 9 10 11 | # Set the layout for 'my.package'
flog.layout(layout.simple, name='my.package')
# Update the ROOT logger to use a custom layout
layout <- layout.format('[~l] [~t] [~n.~f] ~m')
flog.layout(layout)
# Create a custom logger to trace variables
flog.layout(layout.tracearg, name='tracer')
x <- 5
flog.info(x, name='tracer')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.