Closed larshesel closed 5 years ago
So the error appears to be due to no default
configuration being found for the logger.
It would be simple to add a case that handles the error value and returns undefined
in https://github.com/ferd/cth_readable/blob/d9cefd0abb31c151c6dbda53e249f65c225bd7df/src/cth_readable_failonly.erl#L300-L305 (although that may cause breakage in other parts of the setup and might need to force a skipping of logger forwarding altogether)
But I'd like to know if you have any special configurations or changes that are made such that you do not have a default
value for logger. That's definitely weird, but might possibly happen in cases where your own tests change a bunch of values, delete them, or something to that effect.
So I think I found out what the problem is, simply starting lager has the effect of removing the default logger:
1> application:ensure_all_started(lager).
{ok,[syntax_tools,compiler,goldrush,lager]}
2> logger:get_handler_config().
[#{filter_default => log,filters => [],
formatter => {logger_formatter,#{}},
id => error_logger,level => info,module => error_logger}]
And we do start lager in the eunit tests, which then trips over when the common tests are started. I found this over on the lager
repo: https://github.com/erlang-lager/lager/pull/488, so this is on purpose.
Do you know if there are any conventions on which logger should / must be available? Is rebar3
making an (un)reasonable assumption that there's a default handler or is lager
?
There is no standard about anything. I'm just guessing as I go trying to support people's setup, and it's all very reactive. Lager didn't use to have support for logger and therefore wouldn't impact it, so that's a new thing to take into consideration that did not exist before.
https://github.com/ferd/cth_readable/pull/23 might patch it. I'm tired though so I'll double-check tomorrow before publishing and opening a PR here.
Tested with:
and the reported problem seems to be fixed by the patch. Thank you @ferd!
I just tested your patch and common test no longer crashes. Thanks a lot!
Pre-Check
Environment
Current behaviour
When running
rebar3 do eunit, ct
on VerneMQ master (https://github.com/vernemq/vernemq/) we end up with the following error:It should be noted no errors occur if running simply
rebar3 ct
. Also, if run with--readable=false
no error happens, this is similar to #1778, but since that was fixed this is probably something else.The above error also happens with the rebar3 version on master (3.9.1)
The
DEBUG=1
output can be found in this gist: https://gist.github.com/larshesel/4422fb3d13a51c9940473c1d0601d4a6And the output from the CT Log:
Expected behaviour
running
rebar3 do eunit, ct
should work without errors.