Elixir 1.19: Replace ugly old logger config checks with config merging

Side note: Going up in log levels doesn't work properly.
 - debug->info works
 - info->debug does not work
This commit is contained in:
Phantasm 2026-01-14 13:49:31 +01:00 • committed by Phantasm
commit 0f262bb2f3
3 changed files with 51 additions and 60 deletions

View file

@ -392,11 +392,12 @@ defmodule Pleroma.Config.DeprecationWarningsTest do
describe "check_deprecated_logger_config" do
setup do
Application.put_env(:logger, :backends, [:console, {ExSyslogger, :ex_syslogger}])
Application.put_env(:logger, :console, level: :warning)
Application.put_env(:logger, :console, level: :debug)
on_exit(fn ->
Application.delete_env(:logger, :backends)
Application.delete_env(:logger, :console)
:logger.update_handler_config(:default, :formatter, Logger.default_formatter())
end)
end
@ -432,5 +433,22 @@ defmodule Pleroma.Config.DeprecationWarningsTest do
`:default_formatter`. For more info visit: https://hexdocs.pm/logger/Logger.html#module-backends-and-backwards-compatibility
"""
end
test "reconfigures logger" do
log =
capture_log(fn ->
Pleroma.Config.DeprecationWarnings.check_deprecated_logger_config()
end)
# Formatter has inconsitent color formatting order
assert log =~
"""
Reconfiguring console Logger with deprecated configuration syntax.
Handler configuration:
[level: :debug]
Formatter:
"""
end
end
end