Hello, I'm curious to know how people log their applications in R. It seems like it's a combination of cat statements or writing out the session to a file, given the discussions I've had with people. This is fine for interactive work but is a little lacking for automated systems. To address this, I've written a logging facility modeled on the log4j Java library. The basic concept is that you can route logging statements to customizable loggers, each with their own 'threshold' (e.g. debug, info, warn) and output. The output can be anything from stdout, a file, a URL, to a message bus, depending on the implementation.
Here are some quick examples: library(futile) # Use the ROOT logger logger.info("Hello, world") logger.debug("Won't print since level is currently INFO") setLogger('ROOT', level='DEBUG') logger.debug("This will %s print", 'now') # Create new loggers addLogger('a.logger', 'WARN', logger.stdout) addLogger('b.logger', 'INFO', logger.file, file='temp.log') object <- 1 logger.debug("This is a %s", class(object), logger='a.logger') logger.warn("This is a %s", class(object), logger='b.logger') This type of control also provides an alternative to stdout redirection in distributed environments, which can facilitate debugging. Version 1.1.1 of the package is available on CRAN. Any thoughts on how to improve this or requests for other loggers are appreciated. Regards, Brian ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.