Usage
# 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, ...)Details
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.
- ~l
- Log level
- ~t
- Timestamp
- ~n
- Namespace
- ~f
- The
calling function
- ~m
- 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.