<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">If I'm not mistaken, this is also the reason eunit tests do not capture<br>logger messages, making it hard to understand what was logged by a<br>specific failing test.</blockquote>What do you mean by "eunit doesn't capture logger messages"? <br>Is it some specific case? <br>I have had some problems with capturing messages but it was my fault - <br>I misspointed the config file with logger_level set higher than the category of my messages. <br>And another issue was with common_test. <br><div>You must enable verbose output to be able to see messages. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">пн, 10 мая 2021 г. в 09:24, Lukas Larsson <<a href="mailto:lukas@erlang.org">lukas@erlang.org</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 10, 2021 at 8:08 AM Nicolas Martyanoff <<a href="mailto:khaelin@gmail.com" target="_blank">khaelin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Lukas Larsson <<a href="mailto:lukas@erlang.org" target="_blank">lukas@erlang.org</a>> writes:<br>
> However, since logger does not use the group_leader of the calling process<br>
> to print log messages, those messages get sent directly to the `user`<br>
> process which has no notion of whether a shell is actually running or not,<br>
> so it cannot rewrite the output.<br>
<br>
If I'm not mistaken, this is also the reason eunit tests do not capture<br>
logger messages, making it hard to understand what was logged by a<br>
specific failing test.<br></blockquote><div><br></div><div>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.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Is there something on the roadmap to try to address this issue ? It<br>
affects both shell and eunit in non-trivial ways. The only workaround is<br>
to ignore logger in applications and to write another log system which<br>
uses the group leader, so it would make sense to fix logger.<br></blockquote><div><br></div><div>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`.</div><div><br></div><div>Similar functionality is already available in common_test as cth_log_redirect, <a href="http://erlang.org/doc/apps/common_test/ct_hooks_chapter.html#built-in-cths" target="_blank">http://erlang.org/doc/apps/common_test/ct_hooks_chapter.html#built-in-cths</a>. I believe that rebar3 does something similar for their common_test logs.</div><div><br></div><div>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`.</div><div><br></div><div>Lukas</div></div></div>
</blockquote></div>