Hi James,

I did recognized Translator but not so sure about its capability.
With your pointing I tried that path, and it seems it works well and suits 
our need.

I first thought implementing a Translator is a bit too much, so make it 
just configurable might be better.
But simple filter and delegate like below just did the trick:
def translate(_min_level, :info, :report,{:progress, _data}), do: :skip
def translate(min_level, level, kind, message), do: Logger.Translator.
translate(min_level, level, kind, message)

Thanks for your instruction!

Regards,
Yu

2016年10月7日金曜日 19時54分34秒 UTC+9 James Fish:
>
> Hello Yu,
>
> The handle_*_reports config determines whether an event is sent to the 
> translators (
> http://elixir-lang.org/docs/v1.3/logger/Logger.Translator.html). A 
> translator can determine how to format the event or to skip it. You could 
> add a translator that skips progress reports.
>
> Best,
>
> James
>
> On 7 October 2016 at 07:00, Yu Matsuzawa <ymt...@gmail.com <javascript:>> 
> wrote:
>
>> I'm trying to implement email reporter backend for Logger, which should 
>> handle any type of errors/error reports and send them (with sufficient 
>> buffering/throttling) to our alert mailing list.
>> The intention is to handle both errors reported via Elixir.Logger and 
>> Erlang's error_logger (OTP reports and SASL reports).
>>
>> Currently, we are utilizing :errlog_type config option for :sasl 
>> application, which allow us to suppress progress report from supervisors by 
>> setting it to :error level.
>> As you know, supervisors aggressively reports their progresses, so 
>> without this logs are greatly bloated.
>>
>> The point is, in :logger application, there is no equivalent to :sasl's 
>> :errlog_type when :handle_sasl_reports are set to true.
>> There is :level option, but (I believe,) it affects globally in Logger, 
>> thus setting it to :error suppresses :info level log from Elixir.Logger, 
>> too.
>>
>> I am aware that setting log levels separately for error_logger 
>> redirections and Elixir.Logger logs, is a bit too specific.
>> However, suppressing just supervisor's progress report, might be somewhat 
>> common demand, so I opened this thread to request a config option to 
>> achieve this in Elixir.Logger.
>>
>> My rough thought for implementation:
>> 1. Add something like :handle_supervisor_progress option, defaults to 
>> true.
>> config :logger, [
>>   handle_sasl_reports: true,
>>   handle_supervisor_progress: false,
>> ]
>>
>> 2. The value is held in :progress field of the state in 
>> Elixir.Logger.ErrorHandler, and handle :progress report only when it is 
>> true.
>> error_handler.ex#L67 
>> <https://github.com/elixir-lang/elixir/blob/master/lib/logger/lib/logger/error_handler.ex#L67>
>>   defp log_event({:info_report, _gl, {pid, :progress, data}}, %{sasl: 
>> true, progress: true} = state),
>>     do: log_event(:info, :report, pid, {:progress, data}, state)
>>
>> Would be glad to hear your thoughts. Thanks for reading!
>>
>> Regards,
>> Yu
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "elixir-lang-core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to elixir-lang-co...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/elixir-lang-core/2562e8fa-2d07-481b-8f6e-54214860efdf%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/elixir-lang-core/2562e8fa-2d07-481b-8f6e-54214860efdf%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/42db41bf-4a84-4ae9-8ffa-8da662792f6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to