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

1
2
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.

Author(s)

Xiaobei Zhao

See Also

printme

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## 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

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.