LayoutGlue | R Documentation |
Format a LogEvent as human readable text using glue::glue. The function is evaluated in an environment in which it has access to all elements of the LogEvent (see examples). This is more flexible than LayoutFormat, but also more complex and slightly less performant.
lgr::Layout
-> LayoutGlue
fmt
A string that will be interpreted by glue::glue()
new()
LayoutGlue$new( fmt = "{pad_right(colorize_levels(toupper(level_name)), 5)} [{timestamp}] {msg}" )
format_event()
LayoutGlue$format_event(event)
set_fmt()
LayoutGlue$set_fmt(x)
set_colors()
LayoutGlue$set_colors(x)
toString()
LayoutGlue$toString()
clone()
The objects of this class are cloneable with this method.
LayoutGlue$clone(deep = FALSE)
deep
Whether to make a deep clone.
lgr exports a number of formatting utility functions that are
useful for layout glue: colorize_levels()
, pad_left()
, pad_right()
.
Other Layouts:
Layout
,
LayoutFormat
,
LayoutJson
lg <- get_logger("test")$
set_appenders(AppenderConsole$new())$
set_propagate(FALSE)
lg$appenders[[1]]$set_layout(LayoutGlue$new())
lg$fatal("test")
# All fields of the LogEvent are available, even custom ones
lg$appenders[[1]]$layout$set_fmt(
"{logger} {level_name}({level}) {caller}: {toupper(msg)} {{custom: {custom}}}"
)
lg$fatal("test", custom = "foobar")
lg$config(NULL) # reset logger config
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.