Elixir 1.19: Add deprecation warning for :logger, :console configs
This commit is contained in:
parent
a4137243b6
commit
6ffd25682d
2 changed files with 54 additions and 17 deletions
|
|
@ -419,22 +419,42 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
||||||
|
|
||||||
@spec check_deprecated_logger_config() :: :ok | :error
|
@spec check_deprecated_logger_config() :: :ok | :error
|
||||||
def check_deprecated_logger_config do
|
def check_deprecated_logger_config do
|
||||||
if Application.get_env(:logger, :backends) do
|
backend = if Application.get_env(:logger, :backends) do
|
||||||
Logger.warning("""
|
Logger.warning("""
|
||||||
!!!DEPRECATION WARNING!!!
|
!!!DEPRECATION WARNING!!!
|
||||||
Your configuration is using deprecated syntax for configuring backends of Elixir's logger.
|
Your configuration is using deprecated syntax for configuring backends of Elixir's logger.
|
||||||
`config :logger, backends: [...]` is deprecated syntax due to changes in Elixir.
|
`config :logger, backends: [...]` is deprecated syntax due to changes in Elixir.
|
||||||
Please update your configuration at your earliest convenience to use:
|
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.
|
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`
|
`config :logger, :default_handler: false`
|
||||||
""")
|
""")
|
||||||
|
|
||||||
:error
|
true
|
||||||
else
|
else
|
||||||
:ok
|
false
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -392,27 +392,44 @@ defmodule Pleroma.Config.DeprecationWarningsTest do
|
||||||
describe "check_deprecated_logger_config" do
|
describe "check_deprecated_logger_config" do
|
||||||
setup do
|
setup do
|
||||||
Application.put_env(:logger, :backends, [:console, {ExSyslogger, :ex_syslogger}])
|
Application.put_env(:logger, :backends, [:console, {ExSyslogger, :ex_syslogger}])
|
||||||
|
Application.put_env(:logger, :console, level: :warning)
|
||||||
|
|
||||||
on_exit(fn ->
|
on_exit(fn ->
|
||||||
Application.delete_env(:logger, :backends)
|
Application.delete_env(:logger, :backends)
|
||||||
|
Application.delete_env(:logger, :console)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "warns on deprecated syntax" do
|
test "warns on deprecated syntax" do
|
||||||
assert capture_log(fn ->
|
log = capture_log(fn ->
|
||||||
Pleroma.Config.DeprecationWarnings.check_deprecated_logger_config()
|
Pleroma.Config.DeprecationWarnings.check_deprecated_logger_config()
|
||||||
end) =~
|
end)
|
||||||
|
|
||||||
|
assert log =~
|
||||||
"""
|
"""
|
||||||
!!!DEPRECATION WARNING!!!
|
!!!DEPRECATION WARNING!!!
|
||||||
Your configuration is using deprecated syntax for configuring backends of Elixir's logger.
|
Your configuration is using deprecated syntax for configuring backends of Elixir's logger.
|
||||||
`config :logger, backends: [...]` is deprecated syntax due to changes in Elixir.
|
`config :logger, backends: [...]` is deprecated syntax due to changes in Elixir.
|
||||||
Please update your configuration at your earliest convenience to use:
|
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.
|
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`
|
`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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue