layouts: Layouts

layoutsR Documentation

Layouts

Description

In log4j etymology, Layouts are how Appenders control the format of messages.

Some general-purpose layouts are described below.

For implementing your own layouts, see Details.

Usage

default_log_layout(time_format = "%Y-%m-%d %H:%M:%S")

simple_log_layout()

bare_log_layout()

logfmt_log_layout()

json_log_layout()

Arguments

time_format

A valid format string for timestamps. See base::strptime(). For some layouts this can be NA to elide the timestamp.

Details

Layouts are implemented as functions with the interface ⁠function(level, ...)⁠ and returning a single string.

json_log_layout requires the jsonlite package.

Examples

# The behaviour of a layout can be seen by using them directly:
simple <- simple_log_layout()
simple("INFO", "Input has length ", 0, ".")

with_timestamp <- default_log_layout()
with_timestamp("INFO", "Input has length ", 0, ".")


log4r documentation built on Oct. 12, 2024, 9:06 a.m.