[erlang-questions] Prevent my crashing gen_server to produce any error message

Frank Muller frank.muller.erl@REDACTED
Tue Sep 11 17:24:00 CEST 2018


Hi Siri

The filter helped a lot and  less noise are shown on the console. But as
you said, not everything is dropped and I can still see a badmatch crash
report for example.

Can you please explain us the PID idea inside the metadata as I’m not
familiar with the new logger module?

Thanks
/Frank

Le mar. 11 sept. 2018 à 14:09, Siri Hansen <erlangsiri@REDACTED> a écrit :

> With logger (OTP-21.x) you can use process metadata and a filter. For
> example, in your process' init function, call:
> logger:set_process_metadata(#{dont_log=>true}).
>
> Then add a filter which checks for this meta and stops the log - something
> like:
> logger:add_primary_filter(my_filter_id,{fun(#{meta:=#{dont_log:=true}}) ->
> stop; (_,_) -> ignore end,ok}).
>
> This will turn off all logs issued from the process itself, that is, the
> termination report from gen_server, the crash report from proc_lib, and any
> other log issued with the logger API.
>
> It will, however, not turn off the logs issued by the emulator after the
> process has crashed, i.e. the error report saying "Error in process <...>
> with exit reason ..." The reason for this is that the emulator has no
> knowledge of the process metadata, and can not include it in the log event.
> Therefore, to turn off these messages, you need a filter which can
> recognize the pid (which is still part of the metadata in this error
> report). But this is no problem if we're only talking about gen_server
> processes, since the emulator does not issue error reports for such
> processes.
>
> Best Regards
> /siri
>
>
>
>
>
> Den tir. 11. sep. 2018 kl. 09:50 skrev Frank Muller <
> frank.muller.erl@REDACTED>:
>
>> Hi,
>>
>> I found this old thread: is there a way to prevent a crashing process
>> from sending a message to error_logger?
>>
>> http://erlang.org/pipermail/erlang-questions/2017-September/093407.html
>>
>> but I’m wondering if there is a documented, non-documented or even a
>> hackish way to disable error reports for certain (gen_server) processes
>> (Erlang 20.x or 21.x)?
>>
>> Thanks for you help/feedbacks
>> /Frank
>>
> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180911/feeccce7/attachment.htm>


More information about the erlang-questions mailing list