silencing the error logger
ulf.wiger at erlang-solutions.com
Sun Sep 12 09:28:28 EDT 2010
On 09/11/2010 11:51 PM, Tuncer Ayaz wrote:
> What about adding a rebar.config option and controlled by that do
>> application:set_env(sasl, errlog_type, error)
>> application:set_env(kernel, error_logger, silent)
> If that works for you it has a higher chance of getting included than
> modifying the escript invocation line for everybody.
Heh, after even more digging, I found the source of my confusion.
The perils of Open Source programming, and not carefully vetting
all changes that go into your own project... there was a call to
application:start(sasl) in a helper function to the quickcheck
suite, and that call was responsible for inserting the sasl
report handler and causing lots of output. I thought it was
quite annoying and inexplicable that the SASL reports kept
coming out when sasl wasn't even running... <blush/>
(I would never have put the start function there, so that it
essentially tried before every single test to start sasl.
So what if it fails 99% of the time, when you don't check
the return value anyway...? Also, since the error logger _had_
been pretty well silenced, it didn't report sasl being started.)
Once that call was removed, it is enough to have a call to
delete the tty handler from error_logger in the right place:
and normal rebar will do just fine. :)
Still, interestingly, calling error_handler:swap_handler(silent)
will not work, nor will calling
application:set_env(sasl,errlog_type,error) before the call to
application:start(sasl). However, this last problem is (duh)
because the app hasn't been loaded yet. The call to start will
load the app, if it hasn't been already, so if you want to use
application:set_env/3, you have to ensure that the app is loaded first.
The whole system around the error logger is quite intricate.
Sorry for the noise. Hopefully sharing the solution will be
instructive to some.
More information about the rebar