Skip to content

Commit ab9ecf2

Browse files
haulethjosevalim
authored andcommitted
fix(logger): use correct return value from report_cb/2 (#9798)
Earlier it assumed that the return type is the same as in `report_cb/1` which is not true. `report_cb/1` returns format string and data while `report_cb/2` returns already formatted string.
1 parent eca8092 commit ab9ecf2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/logger/lib/logger/handler.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ defmodule Logger.Handler do
230230
translate_fallback(:format, callback.(data), meta, truncate)
231231
end
232232

233-
defp translate_fallback(:report, {:logger, data}, %{report_cb: callback} = meta, truncate)
233+
defp translate_fallback(:report, {:logger, data}, %{report_cb: callback}, _truncate)
234234
when is_function(callback, 2) do
235235
translator_opts =
236236
struct(Inspect.Opts, Application.fetch_env!(:logger, :translator_inspect_opts))
@@ -241,7 +241,7 @@ defmodule Logger.Handler do
241241
single_line: false
242242
}
243243

244-
translate_fallback(:format, callback.(data, opts), meta, truncate)
244+
callback.(data, opts)
245245
end
246246

247247
defp translate_fallback(:format, {format, args}, _meta, truncate) do

lib/logger/test/logger/handler_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,6 @@ defmodule Logger.HandlerTest do
147147
defp format_report(report, opts) do
148148
send(self(), {:format, report, opts})
149149

150-
{'~p', [report]}
150+
inspect(report)
151151
end
152152
end

0 commit comments

Comments
 (0)