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

Stanislav Ledenev <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAOkK=AL9hUQX2+dGr9sSTdZK7aEf2nd6zXiXqMmmy8KOc4qmrQ@mail.gmail.com>
>
> 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 <[email protected]>:

>
>
> On Mon, May 10, 2021 at 8:08 AM Nicolas Martyanoff <[email protected]>
> wrote:
>
>> Lukas Larsson <[email protected]> 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
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.