Skip to contents

Generate log layout function rendering JSON

Usage

layout_json(fields = default_fields())

Arguments

fields

character vector of field names to be included in the JSON

Value

character vector

Note

This functionality depends on the jsonlite package.

Examples

log_layout(layout_json())
log_info(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","msg":"42"}
log_info("ok {1:3} + {1:3} = {2*(1:3)}")
#> {"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","msg":"ok 1 + 1 = 2"}
#> {"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","msg":"ok 2 + 2 = 4"}
#> {"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","msg":"ok 3 + 3 = 6"}