Restrict Logger.configure on config_change callback (#10388)

The `config_change` callback is called from `application_controller` process,
which is receiving env updates on releases. `Logger.configure` does a blocking
call to the `Logger` process, which calls `Application.put_env`

This causes a crash on logger config update.

The fix is to call `Logger.configure` only for the config that have not yet
been persisted.
This commit is contained in:
Daniil Fedotov
2020-10-03 08:33:31 +02:00
committed by José Valim
parent e1cb898198
commit b96fc39422
2 changed files with 5 additions and 2 deletions
+3 -1
View File
@@ -62,7 +62,9 @@ defmodule Logger.App do
@doc false
def config_change(changed, _new, _removed) do
Logger.configure(changed)
# All other config has already been persisted, we only need to
# update the level and reload the logger state.
Logger.configure(Keyword.take(changed, [:level]))
end
@doc """
+2 -1
View File
@@ -647,7 +647,8 @@ defmodule LoggerTest do
:ok = Logger.configure(level: :debug)
try do
assert Logger.App.config_change([level: :error], [], []) === :ok
assert Application.put_env(:logger, :level, :error) === :ok
assert :application_controller.config_change(logger: [level: :debug]) === :ok
assert Logger.level() === :error
after
Logger.configure(level: :debug)