Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/elixir/lib/dynamic_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -963,21 +963,21 @@ defmodule DynamicSupervisor do
end
end

defp report_error(error, reason, pid, child, %{name: name}) do
defp report_error(error, reason, pid, child, %{name: name, extra_arguments: extra}) do
:error_logger.error_report(
:supervisor_report,
supervisor: name,
errorContext: error,
reason: reason,
offender: extract_child(pid, child)
offender: extract_child(pid, child, extra)
)
end

defp extract_child(pid, {mfa, restart, shutdown, type, _modules}) do
defp extract_child(pid, {{m, f, args}, restart, shutdown, type, _modules}, extra) do
[
pid: pid,
id: :undefined,
mfargs: mfa,
mfargs: {m, f, extra ++ args},
restart_type: restart,
shutdown: shutdown,
child_type: type
Expand Down
24 changes: 24 additions & 0 deletions lib/logger/test/logger/translator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,26 @@ defmodule Logger.TranslatorTest do
"""
end

test "translates DynamicSupervisor reports extra_arguments in in abnormal shutdown" do
assert capture_log(:info, fn ->
trap = Process.flag(:trap_exit, true)

{:ok, pid} =
DynamicSupervisor.start_link(strategy: :one_for_one, extra_arguments: [:extra])

child = %{id: __MODULE__, start: {__MODULE__, :abnormal2, [:args]}}
{:ok, _pid2} = DynamicSupervisor.start_child(pid, child)
Process.exit(pid, :normal)
receive do: ({:EXIT, ^pid, _} -> :ok)
Process.flag(:trap_exit, trap)
end) =~ ~r"""
\[error\] Child :undefined of Supervisor #PID<\d+\.\d+\.\d+> \(Supervisor\.Default\) shutdown abnormally
\*\* \(exit\) :stop
Pid: #PID<\d+\.\d+\.\d+>
Start Call: Logger.TranslatorTest.abnormal2\(:extra, :args\)
"""
end

test "translates :supervisor_bridge progress" do
assert capture_log(:info, fn ->
trap = Process.flag(:trap_exit, true)
Expand Down Expand Up @@ -804,6 +824,10 @@ defmodule Logger.TranslatorTest do
:proc_lib.start_link(__MODULE__, :abnormal_init, [])
end

def abnormal2(:extra, :args) do
:proc_lib.start_link(__MODULE__, :abnormal_init, [])
end

def abnormal_init() do
Process.flag(:trap_exit, true)
:proc_lib.init_ack({:ok, self()})
Expand Down