Feature request: Config option for :logger to suppress (ignore) progress report from supervisors

407 views
Skip to first unread message

Yu Matsuzawa

unread,
Oct 7, 2016, 2:00:08 AM10/7/16
to elixir-lang-core
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.
  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

James Fish

unread,
Oct 7, 2016, 6:54:34 AM10/7/16
to elixir-l...@googlegroups.com
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

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/2562e8fa-2d07-481b-8f6e-54214860efdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yu Matsuzawa

unread,
Oct 11, 2016, 5:06:57 AM10/11/16
to elixir-lang-core
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:
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages