Skip to contents

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

Note

This functionality depends on the jsonlite package.

Examples

log_formatter(formatter_json)
log_info(everything = 42)
#> INFO [2024-10-21 07:31:17] {"everything":42}

log_layout(layout_json_parser())
log_info(everything = 42)
#> {"time":"2024-10-21 07:31:17","level":"INFO","ns":"global","ans":"global","topenv":"R_GlobalEnv","fn":"eval","node":"fv-az1198-739","arch":"x86_64","os_name":"Linux","os_release":"6.5.0-1025-azure","os_version":"#26~22.04.1-Ubuntu SMP Thu Jul 11 22:33:04 UTC 2024","pid":8176,"user":"runner","everything":42}

log_layout(layout_json_parser(fields = c("time", "node")))
log_info(cars = row.names(mtcars), species = unique(iris$Species))
#> {"time":"2024-10-21 07:31:17","node":"fv-az1198-739","cars":["Mazda RX4","Mazda RX4 Wag","Datsun 710","Hornet 4 Drive","Hornet Sportabout","Valiant","Duster 360","Merc 240D","Merc 230","Merc 280","Merc 280C","Merc 450SE","Merc 450SL","Merc 450SLC","Cadillac Fleetwood","Lincoln Continental","Chrysler Imperial","Fiat 128","Honda Civic","Toyota Corolla","Toyota Corona","Dodge Challenger","AMC Javelin","Camaro Z28","Pontiac Firebird","Fiat X1-9","Porsche 914-2","Lotus Europa","Ford Pantera L","Ferrari Dino","Maserati Bora","Volvo 142E"],"species":["setosa","versicolor","virginica"]}