lgr (version 0.3.3)

LayoutJson: Format LogEvents as JSON

Description

Format a LogEvent as JSON

Arguments

Usage

x <- LayoutJson$new(toJSON_args = list(auto_unbox = TRUE))

x$clone(deep = FALSE) x$format_event(event) x$set_toJSON_args(x) x$toString()

x$toJSON_args

Creating a New Layout

Layouts are instantiated with <LayoutSubclass>$new(). For a description of the arguments to this function please refer to the Fields section.

Fields

toJSON_args, set_toJSON_args()

a list of values passed on to jsonlite::toJSON()

Methods

format_event(event)

format a LogEvent

See Also

read_json_lines(), http://jsonlines.org/

Other Layouts: LayoutDbi, LayoutFormat, LayoutGlue, Layout

Examples

Run this code
# NOT RUN {
# 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)

# }

Run the code above in your browser using DataCamp Workspace