Erlang (OTP 21+) Logger Console Output Question (Garbled Prompt)
Lukas Larsson
lukas@REDACTED
Mon May 10 08:24:14 CEST 2021
On Mon, May 10, 2021 at 8:08 AM Nicolas Martyanoff <khaelin@REDACTED>
wrote:
> Lukas Larsson <lukas@REDACTED> writes:
> > However, since logger does not use the group_leader of the calling
> process
> > to print log messages, those messages get sent directly to the `user`
> > process which has no notion of whether a shell is actually running or
> not,
> > so it cannot rewrite the output.
>
> If I'm not mistaken, this is also the reason eunit tests do not capture
> logger messages, making it hard to understand what was logged by a
> specific failing test.
>
I'm not really familiar with how eunit handles input/output during
testcases, but this together with the fact that applications log to `user`
will make it hard for eunit to get the output it needs.
> Is there something on the roadmap to try to address this issue ? It
> affects both shell and eunit in non-trivial ways. The only workaround is
> to ignore logger in applications and to write another log system which
> uses the group leader, so it would make sense to fix logger.
>
There is no need to write another log system, you only need to write a
logger backend that outputs to the group_leader of the calling process
instead of `user`.
Similar functionality is already available in common_test as
cth_log_redirect,
http://erlang.org/doc/apps/common_test/ct_hooks_chapter.html#built-in-cths.
I believe that rebar3 does something similar for their common_test logs.
I suppose that the big question is whether we can change the default
behaviour of logger to be that it should output to the `standard_io` of the
calling process instead of `user`.
Lukas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210510/02efa9b1/attachment.htm>
More information about the erlang-questions
mailing list