Skip to content

Commit fca5f1c

Browse files
mitchellhenkeJosé Valim
authored andcommitted
Translate process crash on node in Logger (#9020)
Signed-off-by: José Valim <[email protected]>
1 parent 153ec43 commit fca5f1c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/logger/lib/logger/translator.ex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,19 @@ defmodule Logger.Translator do
126126

127127
{:ok, msg, metadata}
128128

129+
{'Error in process ' ++ _, [pid, node, {reason, stack}]} ->
130+
reason = Exception.normalize(:error, reason, stack)
131+
132+
msg = [
133+
"Process ",
134+
inspect(pid),
135+
" on node ",
136+
inspect(node),
137+
" raised an exception" | format(:error, reason, stack)
138+
]
139+
140+
{:ok, msg, [crash_reason: exit_reason(:error, reason, stack)]}
141+
129142
{'Error in process ' ++ _, [pid, {reason, stack}]} ->
130143
reason = Exception.normalize(:error, reason, stack)
131144
msg = ["Process ", inspect(pid), " raised an exception" | format(:error, reason, stack)]

lib/logger/test/logger/translator_test.exs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,19 @@ defmodule Logger.TranslatorTest do
981981
assert {:stop, [_ | _]} = process_metadata[:crash_reason]
982982
end
983983

984+
test "translates process crash with erts" do
985+
assert {:ok, msg, meta} =
986+
Logger.Translator.translate(
987+
:error,
988+
:error,
989+
:format,
990+
{'Error in process ~p on node ~p with exit value:~n~p~n',
991+
[self(), :"[email protected]", {:badarith, [{:erlang, :/, [1, 0], []}]}]}
992+
)
993+
994+
assert Keyword.get(meta, :crash_reason)
995+
end
996+
984997
test "reports :undefined MFA properly" do
985998
defmodule WeirdFunctionNamesGenServer do
986999
use GenServer

0 commit comments

Comments
 (0)