R/log_levels.R
standardize_threshold.Rd
These are helper functions for verifying log levels and converting them from their character to their integer representations. This is primarily useful if you want to build your own Loggers, Appenders or Layouts and need to handle log levels in a way that is consistent with lgr .
a character
or integer
scalar, or vector for
standardize_log_levels
named integer
vector of valid log levels
An unnamed integer
vector
Other docs relevant for extending lgr:
LogEvent
,
as_LogEvent()
,
event_list()
standardize_threshold("info")
#> [1] 400
standardize_threshold("all")
#> [1] NA
is_threshold("all")
#> [1] TRUE
is_threshold("foobar")
#> [1] FALSE
standardize_log_level("info")
#> [1] 400
# all is a valid threshold, but not a valid log level
try(is.na(standardize_log_level("all")))
#> Error in standardize_log_level("all") :
#> '"all"' must either the numeric or character representation of one of the following log levels: fatal (100), error (200), warn (300), info (400), debug (500), trace (600)
is_log_level("all")
#> [1] FALSE
# standardized_log_level intentionally only works with scalars, because many
# functions require scalar log level inputs
try(standardize_log_level(c("info", "fatal")))
#> Error : 'c("info", "fatal")' must be a scalar log level
# You can still use standardize_log_levels() (plural) to work with vectors
standardize_log_levels(c("info", "fatal"))
#> [1] 400 100