Erlang (OTP 21+) Logger Console Output Question (Garbled Prompt)

Stanislav Ledenev s.ledenev@REDACTED
Mon May 10 09:51:05 CEST 2021


>
> 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.

What do you mean by "eunit doesn't capture logger messages"?
Is it some specific case?
I have had some problems with capturing messages but it was my fault -
I misspointed the config file with logger_level set higher than the
category of my messages.
And another issue was with common_test.
You must enable verbose output to be able to see messages.

пн, 10 мая 2021 г. в 09:24, Lukas Larsson <lukas@REDACTED>:

>
>
> 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/fc774222/attachment.htm>


More information about the erlang-questions mailing list