1
0
Fork 0
mirror of https://git.pleroma.social/pleroma/pleroma.git synced 2026-02-15 17:16:57 +00:00

Elixir 1.19: Add deprecation warning for :logger, :console configs

This commit is contained in:
Phantasm 2026-01-13 21:18:08 +01:00
parent 16e3176895
commit 4656e1ca67
No known key found for this signature in database
GPG key ID: 2669E588BCC634C8
2 changed files with 54 additions and 17 deletions

View file

@ -419,22 +419,42 @@ defmodule Pleroma.Config.DeprecationWarnings do
@spec check_deprecated_logger_config() :: :ok | :error
def check_deprecated_logger_config do
if Application.get_env(:logger, :backends) do
backend = if Application.get_env(:logger, :backends) do
Logger.warning("""
!!!DEPRECATION WARNING!!!
Your configuration is using deprecated syntax for configuring backends of Elixir's logger.
`config :logger, backends: [...]` is deprecated syntax due to changes in Elixir.
Please update your configuration at your earliest convenience to use:
`config :pleroma, :logger, backends: [...]`
`config :logger, backends: [...]`
Pleroma's default configuration will be updated in the next release which WILL override your settings.
Note: :console is no longer considered a backend and is used by default, you can disable it using:
Note: `:console` is no longer considered a backend and is used by default, you can disable it using:
`config :logger, :default_handler: false`
""")
:error
true
else
:ok
false
end
console = if Application.get_env(:logger, :console) do
Logger.warning("""
!!!DEPRECATION WARNING!!!
Your configuration is using deprecated syntax for configuring logging to console.
`config :logger, :console` is deprecated syntax due to changes in Elixir.
Please update your configuration at your earliest convenience to use
`config :logger, default_handler` and `config :logger, :default_formatter`.
Pleroma's default configuration will be updated in the next release which WILL override your settings.
Note: `:default_handler` is used only for the `level` setting. All other configurations go under
`:default_formatter`. For more info visit: https://hexdocs.pm/logger/Logger.html#module-backends-and-backwards-compatibility
""")
true
else
false
end
if backend or console, do: :error, else: :ok
end
end

View file

@ -392,27 +392,44 @@ 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)
on_exit(fn ->
Application.delete_env(:logger, :backends)
Application.delete_env(:logger, :console)
end)
end
test "warns on deprecated syntax" do
assert capture_log(fn ->
log = capture_log(fn ->
Pleroma.Config.DeprecationWarnings.check_deprecated_logger_config()
end) =~
"""
!!!DEPRECATION WARNING!!!
Your configuration is using deprecated syntax for configuring backends of Elixir's logger.
`config :logger, backends: [...]` is deprecated syntax due to changes in Elixir.
Please update your configuration at your earliest convenience to use:
`config :pleroma, :logger, backends: [...]`
Pleroma's default configuration will be updated in the next release which WILL override your settings.
end)
Note: :console is no longer considered a backend and is used by default, you can disable it using:
`config :logger, :default_handler: false`
"""
assert log =~
"""
!!!DEPRECATION WARNING!!!
Your configuration is using deprecated syntax for configuring backends of Elixir's logger.
`config :logger, backends: [...]` is deprecated syntax due to changes in Elixir.
Please update your configuration at your earliest convenience to use:
`config :logger, backends: [...]`
Pleroma's default configuration will be updated in the next release which WILL override your settings.
Note: `:console` is no longer considered a backend and is used by default, you can disable it using:
`config :logger, :default_handler: false`
"""
assert log =~
"""
!!!DEPRECATION WARNING!!!
Your configuration is using deprecated syntax for configuring logging to console.
`config :logger, :console` is deprecated syntax due to changes in Elixir.
Please update your configuration at your earliest convenience to use
`config :logger, default_handler` and `config :logger, :default_formatter`.
Pleroma's default configuration will be updated in the next release which WILL override your settings.
Note: `:default_handler` is used only for the `level` setting. All other configurations go under
`:default_formatter`. For more info visit: https://hexdocs.pm/logger/Logger.html#module-backends-and-backwards-compatibility
"""
end
end
end