log4r: A simple logging system for R, based on log4j.

Javaのロギングユーティリティをもとにしたロギングシステムの導入

> library(log4r)

バージョン: 0.2


関数名 概略
create.logger Creates a logger object.
level Set or get the priority level for a logger object.
levellog Write messages to logs at a given priority level.
log4r-package A simple logging system for R, based on log4j.
logfile Get or set the logfile for a logger object.
logformat Get or set the format string for a logger object.
loglevel Logging levels
write.message A hidden function for handling the writing of logging messages.

create.logger

Arguments

  • logfile
  • level
  • logformat
> logger <- create.logger()

level

> level(logger) <- "INFO"

levellog / debug / info / warn / error / fatal

Arguments

  • logger
  • level
  • message
> debug(logger, 'A Debugging Message')
Error in debug(fun, text, condition): argument must be a closure
> info(logger, 'An Info Message')
> warn(logger, 'A Warning Message')
> error(logger, 'An Error Message')
> fatal(logger, 'A Fatal Error Message')
> readLines("test.log")
[1] "2016-01-13 17:37:53.131 - SIMPLEMESSAGE - output file: luzlogr.md"                
[2] "2016-01-13 17:37:53.136 - SIMPLEMESSAGE -   processing file: log4r.Rmd"           
[3] "2016-01-13 17:37:53.151 - SIMPLEMESSAGE -   processing file: ./../chunk_setup.Rmd"

logfile

> logfile(logger) <- file.path("test.log")