logger.setup: Set Up Python-Style Logging

Description Usage Arguments Value Note See Also Examples

View source: R/pylogger.r

Description

Good logging allows package developers and users to create log files at different levels to track and debug lengthy or complex calculations. "Python-style" logging is intended to suggest that users should set up multiple log files for different log severities so that the errorLog will contain only log messages at or above the ERROR level while a debugLog will contain log messages at the DEBUG level as well as all higher levels.

Python-style log files are set up with logger.setup(). Logs can be set up for any combination of log levels. Accepting the default NULL setting for any log file simply means that log file will not be created.

Python-style logging requires the use of logger.debug() style logging statements as seen in the example below.

Usage

1
2
logger.setup(traceLog = NULL, debugLog = NULL, infoLog = NULL,
  warnLog = NULL, errorLog = NULL, fatalLog = NULL)

Arguments

traceLog

file name or full path where logger.trace() messages will be sent

debugLog

file name or full path where logger.debug() messages will be sent

infoLog

file name or full path where logger.info() messages will be sent

warnLog

file name or full path where logger.warn() messages will be sent

errorLog

file name or full path where logger.error() messages will be sent

fatalLog

file name or full path where logger.fatal() messages will be sent

Value

No return value.

Note

All functionality is built on top of the excellent futile.logger package.

See Also

logger.trace logger.debug logger.info logger.warn logger.error logger.fatal

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
# Only save three log files
logger.setup(debugLog='debug.log', infoLog='info.log', errorLog='error.log')

# But allow lot statements at all levels within the code
logger.trace('trace statement #%d', 1)
logger.debug('debug statement')
logger.info('info statement %s %s', "with", "arguments")
logger.warn('warn statement %s', "about to try something dumb")
result <- try(1/"a", silent=TRUE)
logger.error('error message: %s', geterrmessage())
logger.fatal('fatal statement %s', "THE END")

## End(Not run)

agaveplatform/r-sdk documentation built on Sept. 22, 2018, 2:14 p.m.