> It seems a bit dumb that warning.expression functions can only say
> "Hey, something a bit iffy may have ocurred, but I dont know what and
I
> dont know where!". Maybe there's something in that
cptr->cloenv that can
> tell you...
The way that I intend to begin using this is with non-standard evaluation and
traceback() to determine the context of all warnings in a use case similar to
yours. In particular, traceback(0) will print the entire call stack. As a
result, wrapping the logging / printing into a substitute() call will cause the
expression to be evaluated appropriately on a warning event. If you want to
skip a few messages in the call stack, change the integer you are passing (i.e.
traceback(6) will ignore 6 messages at the end of the call stack - where
internals are being called).
Note that I am using the logging package here, which seems that it might fit
your use case nicely, if configured appropriately. Documentation here:
http://logging.r-forge.r-project.org/
options( warning.expression = {
substitute(
for (m in rev(traceback(0))) {
logging::logwarn(m)
}
)
}
)
[[alternative HTML version deleted]]