Learn R Programming

Xmisc (version 0.2.1)

logme: Log the name and the content of an R object

Description

Log the name and the content of an R object given levels of logger

Usage

logme(x = NULL, prefix = NULL, logger = NULL, envir = sys.frame(sys.parent(0)))

Arguments

x
ANY, an R object.
prefix
the prefix to log.
logger
logging level, one of: NULL, 'INFO', 'DEBUG', 'WARNING', 'ERROR', 'CRITICAL'
envir
the environment to use.

See Also

printme

Examples

Run this code
## log an object
x1 <- 1:6
logme(x1)

## log according to logger levels
bar <- function(x,envir=sys.frame(sys.parent(0))){
  for (.logger in get_loglevel()) {
    if (is.null(.logger)) .prefix <- 'NULL' else .prefix <- .logger
    logme(x,prefix=.prefix,logger=.logger,envir=envir)
  }
}
options(logger='DEBUG')
bar(1:6) # print logs of level NULL, INFO and DEBUG
options(logger='ERROR')
bar(1:6) # print logs of level NULL, INFO, DEBUG, WARNING and ERROR

Run the code above in your browser using DataLab