Skip to content

Conversation

martosaur
Copy link
Contributor

@martosaur martosaur commented Mar 22, 2025

Currently handle_otp_reports logger option doesn't seem to have any effect. It's passed as otp option to Logger.Utils.translator/2 (which is always attached as a primary logger filter) and the only clause that uses this option seemingly can never match. Here's an example:

:logger.remove_primary_filter(:logger_translator)

:logger.add_primary_filter(
  :logger_translator,
  {&Logger.Utils.translator/2, %{otp: false, sasl: false, translators: [{Logger.Translator, :translate}]}}
)

Task.start(fn -> exit("Exit") end)

Process.sleep(1_000)
12:25:45.123 [error] Task #PID<0.97.0> started from #PID<0.94.0> terminating
** (stop) "Exit"
    logger.exs:8: anonymous fn/0 in :elixir_compiler_0.__FILE__/1
    (elixir 1.18.3) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
Function: #Function<0.18661568 in file:logger.exs>
    Args: []

The error is both logged and translated.

This PR changes the clause to drop all events with :otp domain if handle_otp_reports is set to false.

@josevalim josevalim merged commit edd2944 into elixir-lang:main Mar 22, 2025
10 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@martosaur martosaur deleted the am-fix-handle-otp-reports-flag branch March 22, 2025 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants