Closed aammd closed 9 years ago
You don't already? Here's my output:
> library(loggr)
> log_file("console")
2015-06-10 06:26:34.633 - INFO - Activating logging to console
> for (i in 1:11) {Sys.sleep(1); warning("HELLO")}
2015-06-10 06:26:39.653 - SIMPLEWARNING - HELLO
2015-06-10 06:26:40.678 - SIMPLEWARNING - HELLO
2015-06-10 06:26:41.698 - SIMPLEWARNING - HELLO
2015-06-10 06:26:42.745 - SIMPLEWARNING - HELLO
2015-06-10 06:26:43.766 - SIMPLEWARNING - HELLO
2015-06-10 06:26:44.786 - SIMPLEWARNING - HELLO
2015-06-10 06:26:45.795 - SIMPLEWARNING - HELLO
2015-06-10 06:26:46.809 - SIMPLEWARNING - HELLO
2015-06-10 06:26:47.829 - SIMPLEWARNING - HELLO
2015-06-10 06:26:48.836 - SIMPLEWARNING - HELLO
2015-06-10 06:26:49.840 - SIMPLEWARNING - HELLO
There were 11 warnings (use warnings() to see them)
The Sys.sleep(1)
shows that the messages are logged as they happen and not upon return to top level (as the 11 warnings "message").
hm. After some experimenting, the problem doesn't seem to be the number of warnings, but the way they are generated. my log contains warnings from functions I call directly, but not functions that were called by them (actually several "steps" removed from the global environment). Is that potentially a problem?
It could be but it shouldn't be.
Could you produce a small example?
We recently changed the way we hook up warnings and messages, have you tried updating? Currently it will try to ignore muffled warnings although perhaps this should be optional.
As an example, suppose:
f <- function()
{
g <- function()
warning("Inner workings...")
h <- function()
g()
invisible(h())
}
With current loggr
on my machine:
> log_file("console")
2015-06-13 07:35:33.392 - INFO - Activating logging to console
>
> for (i in 1:11) f()
2015-06-13 07:35:33.392 - SIMPLEWARNING - Inner workings...
2015-06-13 07:35:33.392 - SIMPLEWARNING - Inner workings...
2015-06-13 07:35:33.392 - SIMPLEWARNING - Inner workings...
2015-06-13 07:35:33.392 - SIMPLEWARNING - Inner workings...
2015-06-13 07:35:33.392 - SIMPLEWARNING - Inner workings...
2015-06-13 07:35:33.392 - SIMPLEWARNING - Inner workings...
2015-06-13 07:35:33.392 - SIMPLEWARNING - Inner workings...
2015-06-13 07:35:33.392 - SIMPLEWARNING - Inner workings...
2015-06-13 07:35:33.392 - SIMPLEWARNING - Inner workings...
2015-06-13 07:35:33.392 - SIMPLEWARNING - Inner workings...
2015-06-13 07:35:33.392 - SIMPLEWARNING - Inner workings...
There were 11 warnings (use warnings() to see them)
>
> for (i in 1:11) suppressWarnings(f())
>
I believe this is no longer an issue? Otherwise feel free to reopen.
When a line of code returns something like
Is there a way to obtain them?