| LayoutFormat {lgr} | R Documentation |
Format Log Events as Text
Description
Format Log Events as Text
Format Log Events as Text
Details
Format a LogEvent as human readable text using format.LogEvent(), which
provides a quick and easy way to customize log messages. If you need
more control and flexibility, consider using LayoutGlue instead.
see Fields
see Fields
see Fields
see Fields
Convert Layout to a character string
Read a log file written using LayoutFormat
Format Tokens
This is the same list of format tokens as for format.LogEvent()
%tThe timestamp of the message, formatted according to
timestamp_fmt)%lthe log level, lowercase
characterrepresentation%Lthe log level, uppercase
characterrepresentation%kthe log level, first letter of lowercase
characterrepresentation%Kthe log level, first letter of uppercase
characterrepresentation%nthe log level,
integerrepresentation%gthe name of the logger
%pthe PID (process ID). Useful when logging code that uses multiple threads.
%cthe calling function
%mthe log message
%fall custom fields of
xin a pseudo-JSON like format that is optimized for human readability and console output%jall custom fields of
xin proper JSON. This requires that you have jsonlite installed and does not support colors as opposed to%f
Super class
lgr::Layout -> LayoutFormat
Active bindings
fmta
characterscalar containing format tokens. Seeformat.LogEvent().timestamp_fmta
characterscalar. Seebase::format.POSIXct().colorsa named
listof functions (like the ones provided by the package crayon) passed on onformat.LogEvent().pad_levels"right","left"orNULL. Seeformat.LogEvent().
Methods
Public methods
Method new()
Usage
LayoutFormat$new( fmt = "%L [%t] %m %j", timestamp_fmt = "%Y-%m-%d %H:%M:%OS3", colors = NULL, pad_levels = "right" )
Method format_event()
Format a LogEvent
Usage
LayoutFormat$format_event(event)
Arguments
eventa LogEvent
Method set_fmt()
Usage
LayoutFormat$set_fmt(x)
Method set_timestamp_fmt()
Usage
LayoutFormat$set_timestamp_fmt(x)
Method set_colors()
Usage
LayoutFormat$set_colors(x)
Method set_pad_levels()
Usage
LayoutFormat$set_pad_levels(x)
Method toString()
Usage
LayoutFormat$toString()
Method read()
Usage
LayoutFormat$read(file, threshold = NA_integer_, n = 20L)
Arguments
thresholda
characterorintegerthresholdnnumber of log entries to display
Method clone()
The objects of this class are cloneable with this method.
Usage
LayoutFormat$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Layouts:
LayoutGlue,
LayoutJson,
Layout
Examples
# setup a dummy LogEvent
event <- LogEvent$new(
logger = Logger$new("dummy logger"),
level = 200,
timestamp = Sys.time(),
caller = NA_character_,
msg = "a test message"
)
lo <- LayoutFormat$new()
lo$format_event(event)