| print.LogEvent | R Documentation |
Print or Format Logging Data
## S3 method for class 'LogEvent'
print(
x,
fmt = "%L [%t] %m %f",
timestamp_fmt = "%Y-%m-%d %H:%M:%S",
colors = getOption("lgr.colors"),
log_levels = getOption("lgr.log_levels"),
pad_levels = "right",
excluded_fields = NULL,
...
)
## S3 method for class 'LogEvent'
format(
x,
fmt = "%L [%t] %m %f",
timestamp_fmt = "%Y-%m-%d %H:%M:%S",
colors = NULL,
log_levels = getOption("lgr.log_levels"),
pad_levels = "right",
excluded_fields = NULL,
...
)
x |
a LogEvent |
fmt |
A |
timestamp_fmt |
see |
colors |
A |
log_levels |
named |
pad_levels |
|
excluded_fields |
a |
... |
ignored |
x for print() and a character scalar for format()
%tThe timestamp of the message, formatted according to
timestamp_fmt)
%lthe log level, lowercase character representation
%Lthe log level, uppercase character representation
%kthe log level, first letter of lowercase character representation
%Kthe log level, first letter of uppercase character representation
%nthe log level, integer representation
%gthe name of the logger
%pthe PID (process ID). Useful when logging code that uses multiple threads.
%cthe calling function
%mthe log message
%rthe raw log message (without string interpolation)
%fall custom fields of x in a pseudo-JSON like format that is
optimized for human readability and console output
%jall custom fields of x in proper JSON. This requires that you
have jsonlite installed and does not support colors as opposed to
%f
# standard fields can be printed using special tokens
x <- LogEvent$new(
level = 300, msg = "a test event", caller = "testfun()", logger = lgr
)
print(x)
print(x, fmt = c("%t (%p) %c: %n - %m"))
print(x, colors = NULL)
# custom values
y <- LogEvent$new(
level = 300, msg = "a gps track", logger = lgr,
waypoints = 10, location = "Austria"
)
# default output with %f
print(y)
# proper JSON output with %j
if (requireNamespace("jsonlite")){
print(y, fmt = "%L [%t] %m %j")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.