layout_json_parser: Generate log layout function rendering JSON after merging...

View source: R/layouts.R

layout_json_parserR Documentation

Generate log layout function rendering JSON after merging meta fields with parsed list from JSON message

Description

Generate log layout function rendering JSON after merging meta fields with parsed list from JSON message

Usage

layout_json_parser(fields = default_fields())

Arguments

fields

character vector of field names to be included in the JSON. If named, the names will be used as field names in the JSON.

Note

This functionality depends on the jsonlite package.

See Also

Other log_layouts: get_logger_meta_variables(), layout_blank(), layout_glue(), layout_glue_colors(), layout_glue_generator(), layout_json(), layout_logging(), layout_simple()

Examples


log_formatter(formatter_json)
log_info(everything = 42)

log_layout(layout_json_parser())
log_info(everything = 42)

log_layout(layout_json_parser(fields = c("time", "node")))
log_info(cars = row.names(mtcars), species = unique(iris$Species))

log_layout(layout_json_parser(fields = c(timestamp = "time", "node")))
log_info(
  message = paste(
    "Compared to the previous example,
    the 'time' field is renamed to 'timestamp'"
  )
)


daroczig/logger documentation built on Jan. 31, 2025, 6:56 p.m.