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()
if (FALSE) {
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")
}
Run the code above in your browser using DataLab