Format Log Events as Text
Format Log Events as Text
Format Log Events as Text
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
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 character representation
%Lthe log level, uppercase character representation
%kthe log level, first letter of lowercase character representation
%Kthe log level, first letter of uppercase character representation
%nthe log level, integer representation
%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 x in a pseudo-JSON like format that is
optimized for human readability and console output
%jall custom fields of x in proper JSON. This requires that you
have jsonlite installed and does not support colors as opposed to
%f
lgr::Layout -> LayoutFormat
fmta character scalar containing format tokens. See format.LogEvent().
timestamp_fmta character scalar. See base::format.POSIXct().
colorsa named list of functions (like the ones provided by
the package crayon) passed on on format.LogEvent().
pad_levels"right", "left" or NULL. See format.LogEvent().
new()
LayoutFormat$new( fmt = "%L [%t] %m", timestamp_fmt = "%Y-%m-%d %H:%M:%OS3", colors = NULL, pad_levels = "right" )
format_event()
Format a LogEvent
LayoutFormat$format_event(event)
eventa LogEvent
set_fmt()
LayoutFormat$set_fmt(x)
set_timestamp_fmt()
LayoutFormat$set_timestamp_fmt(x)
set_colors()
LayoutFormat$set_colors(x)
set_pad_levels()
LayoutFormat$set_pad_levels(x)
toString()
LayoutFormat$toString()
read()
LayoutFormat$read(file, threshold = NA_integer_, n = 20L)
thresholda character or integer threshold
nnumber of log entries to display
clone()
The objects of this class are cloneable with this method.
LayoutFormat$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Layouts: 
LayoutGlue,
LayoutJson,
Layout
# 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)Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.