Skip to content

Commit a87eb7d

Browse files
committed
Avoid collectable deprecation warning
1 parent 884de18 commit a87eb7d

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

lib/logger/lib/logger/utils.ex

+20-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule Logger.Utils do
1313
def translator(%{meta: %{domain: [:supervisor_report | _]}}, %{sasl: false}), do: :stop
1414
def translator(%{msg: {:string, _}}, _config), do: :ignore
1515

16-
def translator(%{msg: msg, level: level} = event, %{translators: translators}) do
16+
def translator(%{msg: msg, level: level, meta: meta} = event, %{translators: translators}) do
1717
%{level: min_level} = :logger.get_primary_config()
1818

1919
try do
@@ -40,32 +40,39 @@ defmodule Logger.Utils do
4040

4141
%{event | msg: {:string, chardata}}
4242
else
43-
:none -> :ignore
44-
:skip -> :stop
45-
{:ok, chardata} -> return_translated_event(event, chardata)
46-
{:ok, char, meta} -> return_translated_event(event, char, meta)
43+
:none ->
44+
:ignore
45+
46+
:skip ->
47+
:stop
48+
49+
{:ok, chardata} ->
50+
return_translated_event(event, chardata, meta)
51+
52+
{:ok, chardata, translation_meta} ->
53+
return_translated_event(event, chardata, Enum.into(translation_meta, meta))
4754
end
4855
end
4956

5057
def translated_cb(report) do
5158
{~c"~ts", [report[:elixir_translation]]}
5259
end
5360

54-
defp return_translated_event(event, translated, meta \\ [])
55-
56-
defp return_translated_event(%{msg: {:report, report}} = event, translated, meta) do
57-
report = Enum.into([elixir_translation: translated], report)
58-
meta = Enum.into(meta, event.meta)
61+
defp return_translated_event(%{msg: {:report, report}} = event, translation, meta) do
62+
report =
63+
if is_list(report),
64+
do: [elixir_translation: translation] ++ report,
65+
else: Map.put(report, :elixir_translation, translation)
5966

6067
%{
6168
event
6269
| msg: {:report, report},
63-
meta: Enum.into([report_cb: &__MODULE__.translated_cb/1], meta)
70+
meta: Map.put(meta, :report_cb, &__MODULE__.translated_cb/1)
6471
}
6572
end
6673

67-
defp return_translated_event(event, translated, meta) do
68-
%{event | msg: {:string, translated}, meta: Enum.into(meta, event.meta)}
74+
defp return_translated_event(event, translation, meta) do
75+
%{event | msg: {:string, translation}, meta: meta}
6976
end
7077

7178
defp translate([{mod, fun} | t], min_level, level, kind, data) do

0 commit comments

Comments
 (0)