loggr: A Logging Framework for R

> library(loggr)
> log_file(file_name = "test.log")
2016-01-13 17:37:52.940 - INFO - Activating logging to test.log

バージョン: 0.3


関数名 概略
as_log_event Log event conversion methods.
deactivate_log Deactivate Active Log Objects
format_log_entry Default log entry formatter.
log_event Create a log event
log_file Activate a log file
log_info Signal Event to Log File Handlers.
use_logging Activate logging by loggr
write_log_entry Write a log entry to a log file.

log_file

Arguments

  • file_name
  • ...
  • .warning
  • .error
  • .message
  • .formatter
> log_file(file_name = "test.log")
2016-01-13 17:37:52.963 - INFO - Activating logging to test.log
> readLines("test.log")
[1] "2016-01-13 17:37:52.963 - INFO - Activating logging to test.log"
> # 関数名の間違いなど、何らかのエラーを起こすと記録される
> logfile("console")
Error in UseMethod("logfile", x): no applicable method for 'logfile' applied to an object of class "character"
> log_file("console") # stdout
2016-01-13 17:37:52.972 - INFO - Activating logging to console
> readLines("test.log")
[1] "2016-01-13 17:37:52.963 - INFO - Activating logging to test.log"
[2] "2016-01-13 17:37:52.972 - INFO - Activating logging to console"

log_info / log_error / log_debug / log_warn / log_critical / log_with_level

log_ログの種類()という関数名をとる

> log_info(message = "記録するメッセージ")
> log_critical("GLM()という関数はない。正しくはglm()")
> readLines("test.log")