loglevel | R Documentation |
Functions for handling logging levels. With each log entry, a logging level is associated that indicate its severity – debugging output, informational output, warning message, error message or fatal error. Each logger only prints log entries where the log level is equal or above its threshold.
loglevel(i)
is.loglevel(x, ...)
as.loglevel(i)
## S3 method for class 'loglevel'
print(x, ...)
## S3 method for class 'loglevel'
as.numeric(x, ...)
## S3 method for class 'loglevel'
as.character(x, ...)
available.loglevels()
verbosity(v)
i |
An integer from the set 1..5. Otherwise it will be modified sensibly to fit in that range. Alternatively, a named logging level (one of "DEBUG", "INFO", "WARN", "ERROR", or "FATAL"). |
x |
An object of class "loglevel" |
... |
Unused |
v |
A verbosity level from the set 5..1. For historical reasons, they do not match the log levels; a verbosity level of 1 corresponds to a logging level of 5, 2 corresponds to 4, etc. |
To specify a logging level, use a character value, e.g. "WARN"
, or an
integer between 1 and 5. The function available.levels
lists all possible
logging levels.
An object of class "loglevel"
loglevel(2) == loglevel("INFO")
loglevel("WARN") < loglevel("ERROR")
loglevel(-1)
try(loglevel("UNDEFINED"))
is.loglevel("DEBUG")
is.loglevel(loglevel("DEBUG"))
as.numeric(loglevel("FATAL"))
available.loglevels()
## Not run:
library(optparse)
library(log4r)
optlist <- list(make_option(c('-v', '--verbosity-level'),
type = "integer",
dest = "verbosity",
default = 1,
help = "Verbosity threshold (5=DEBUG, 4=INFO 3=WARN, 2=ERROR, 1=FATAL)"))
optparser <- OptionParser(option_list=optlist)
opt <- parse_args(optparser)
my.logger <- create.logger(logfile = "", level = verbosity(opt$verbosity))
fatal(my.logger, "Fatal message")
error(my.logger, "Error message")
warn(my.logger, "Warning message")
info(my.logger, "Informational message")
debug(my.logger, "Debugging message")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.