Skip to content

[R logs] Help in develop a simply logs package

1 message · Thomas J. Leeper

#
Maybe this isn't what you're going for, but to implement the
"ritesink" widget in my package rite (which is a colored tcltk widget
to display output, messages, warnings, and errors), I use a
combination of `sink`, `addTaskCallback`, and a modification of
`options("error")`. In short, the task callback is executed after
every top-level evaluation. The function in that callback reads
contents from `sink`ed output and message streams and, if anything new
has been added to either, it writes those contents to the widget. The
custom error handler similarly writes to the widget instead of the
console. Following this design, instead of writing to the widget, you
could write all of that to some kind of formatted log file.

The package is on CRAN and you can take quick look at the source code
on GitHub: https://github.com/leeper/rite/blob/master/R/ritesink.r

Thomas J. Leeper
http://www.thomasleeper.com
On Wed, Oct 8, 2014 at 12:00 PM, <r-devel-request at r-project.org> wrote: