You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can repro this with a single file application (e.g. test.exs):
Mix.install([:logger_json])
require Logger
formatter = {LoggerJSON.Formatters.Datadog, encoder_opts: [pretty: true]}
:logger.update_handler_config(:default, :formatter, formatter)
defmodule CrashingGenServer do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
end
def init(state) do
{:ok, state}
end
def handle_call(:boom, _, _) do
raise "boom"
end
end
{:ok, _} = Supervisor.start_link([{CrashingGenServer, :ok}], strategy: :one_for_one)
pid = self()
{:ok, _} =
Task.start(fn ->
try do
GenServer.call(CrashingGenServer, :boom)
catch
_ -> nil
after
send(pid, :done)
end
end)
# Wait for task to finish
receive do
:done -> nil
end
# Let logs flush
Process.sleep(100)
Maybe it might make sense to call meta.report_cb if it's set. AFAIK that's what Logger.Formatter does. It might be difficult to handle all possible reports "on our own" (even Elixir fails sometimes: elixir-lang/elixir#13682elixir-lang/elixir#14020) and IMO a less structured meta.report_cb is better than a crash.
UPDATE: LoggerJSON already uses report_cb when available:
Related to #133
You can repro this with a single file application (e.g. test.exs):
Running
elixir test.exs
results in:The text was updated successfully, but these errors were encountered: