Hi there,
so I’m finishing up the packaging of a lib. My last issue is, how on earth do I omit the System reporting?
When running Eunit it by default swallows IO output to the console. I’ve tried adding a profile to rebar3, with:
Ah - I meant the Reports still appear during the test runs, like when a child crashes you get the supervisor/system report on it and I would like to “silence” them during eunit runs, since I’m crashing things on purpose and it “pollutes” the output with a lot of logs?
You’re right, what I wrote doesn’t make sense because I erased part of it before submitting and left that there -_- but yes the the reports DO show on the output and that’s what I want to silence.
EUnit by default captures nothing, and we have added nothing about this either.
We do have an equivalent that exists for Common Test.
If you want to do it in EUnit, you can silence or change the logging level through the setup fixtures. Just call logger:add_handler_filter(default, ?MODULE, {fun(_,_) -> stop end, nostate}) and remove it with logger:remove_handler_filter(default, ?MODULE); at the end of the test.
To do it for all runs, you might want to add the filter_default value to stop to kill it all. I’m not sure whether we do live-reload of configs for eunit the way we do it for CT. That wouldn’t be too hard to add if it’s not there though.
That didn’t work either - I’m not explicitly using the sasl application anywhere though (by what I understood now by default those errors get logged through the regular logger interface? so your first tip should have worked).
Anyway I added this as the first test to the suite {"Turn off logs", fun() -> logger:set_primary_config(level, none) end},
So, I probably didn’t save the changes the second time I ran it (?), because I tried now adding the handler_filter you gave at the start of the suit and indeed it does work… As expected… Thanks!