| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/log_levels.R |
| 3 |
\name{standardize_threshold} |
| 4 |
\alias{standardize_threshold} |
| 5 |
\alias{is_threshold} |
| 6 |
\alias{standardize_log_level} |
| 7 |
\alias{is_log_level} |
| 8 |
\alias{standardize_log_levels} |
| 9 |
\alias{is_log_levels} |
| 10 |
\title{Standardize User-Input Log Levels to Their Integer Representation} |
| 11 |
\usage{ |
| 12 |
standardize_threshold( |
| 13 |
x, |
| 14 |
log_levels = c(getOption("lgr.log_levels"), c(all = NA_integer_, off = 0L)) |
| 15 |
) |
| 16 |
|
| 17 |
is_threshold(x) |
| 18 |
|
| 19 |
standardize_log_level(x, log_levels = getOption("lgr.log_levels")) |
| 20 |
|
| 21 |
is_log_level(x) |
| 22 |
|
| 23 |
standardize_log_levels(x, log_levels = getOption("lgr.log_levels")) |
| 24 |
|
| 25 |
is_log_levels(x) |
| 26 |
} |
| 27 |
\arguments{ |
| 28 |
\item{x}{a \code{character} or \code{integer} scalar, or vector for |
| 29 |
standardize_log_levels} |
| 30 |
|
| 31 |
\item{log_levels}{named \code{integer} vector of valid log levels} |
| 32 |
} |
| 33 |
\value{ |
| 34 |
An unnamed \code{integer} vector |
| 35 |
} |
| 36 |
\description{ |
| 37 |
These are helper functions for verifying log levels and converting them from |
| 38 |
their character to their integer representations. This is primarily useful |
| 39 |
if you want to build your own \link{Loggers}, \link{Appenders} or \link{Layouts} and need |
| 40 |
to handle log levels in a way that is consistent with \pkg{lgr} . |
| 41 |
} |
| 42 |
\examples{ |
| 43 |
|
| 44 |
standardize_threshold("info") |
| 45 |
standardize_threshold("all") |
| 46 |
is_threshold("all") |
| 47 |
is_threshold("foobar") |
| 48 |
|
| 49 |
standardize_log_level("info") |
| 50 |
# all is a valid threshold, but not a valid log level |
| 51 |
try(is.na(standardize_log_level("all"))) |
| 52 |
is_log_level("all") |
| 53 |
|
| 54 |
# standardized_log_level intentionally only works with scalars, because many |
| 55 |
# functions require scalar log level inputs |
| 56 |
try(standardize_log_level(c("info", "fatal"))) |
| 57 |
|
| 58 |
# You can still use standardize_log_levels() (plural) to work with vectors |
| 59 |
standardize_log_levels(c("info", "fatal")) |
| 60 |
} |
| 61 |
\seealso{ |
| 62 |
Other docs relevant for extending lgr: |
| 63 |
\code{\link{LogEvent}}, |
| 64 |
\code{\link{as_LogEvent}()}, |
| 65 |
\code{\link{event_list}()} |
| 66 |
} |
| 67 |
\concept{docs relevant for extending lgr} |