Format LogEvents as JSON
A format for formatting LogEvents as jsonlines log files. This provides a nice balance between human- an machine-readability.
lgr::Layout -> LayoutJson
toJSON_argsa list of values passed on to jsonlite::toJSON()
timestamp_fmtUsed by  $format_event() to format timestamps.
new()
LayoutJson$new(toJSON_args = list(auto_unbox = TRUE), timestamp_fmt = NULL)
format_event()
LayoutJson$format_event(event)
set_toJSON_args()
Set arguments to pass on to jsonlite::toJSON()
LayoutJson$set_toJSON_args(x)
xa named list
set_timestamp_fmt()
Set a format that this Layout will apply to timestamps.
LayoutJson$set_timestamp_fmt(x)
xNULL (the default): formatting of the timestamp is left to
jsonlite::toJSON(),
 a character scalar as for format.POSIXct(), or
 a function that returns a vector of the same length as its
(POSIXct) input. The returned vector can be of any type
supported by jsonlite::toJSON(), but should usually be character.
toString()
LayoutJson$toString()
parse()
LayoutJson$parse(file)
read()
LayoutJson$read(file, threshold = NA_integer_, n = 20L)
clone()
The objects of this class are cloneable with this method.
LayoutJson$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Layouts: 
LayoutFormat,
LayoutGlue,
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",
  custom_field = "LayoutJson can handle arbitrary fields"
)
# Default settings show all event fals
lo <- LayoutJson$new()
lo$format_event(event)Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.