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

Description Usage Arguments Author(s) See Also Examples

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

Xmisc documentation built on May 2, 2019, 8:23 a.m.