logger backends fix

This commit is contained in:
Alexander 2019-12-19 10:19:56 +03:00 committed by Alexander Strizhakov
parent 583cee4607
commit 063ab6d911
No known key found for this signature in database
GPG key ID: 022896A53AEF1381
2 changed files with 38 additions and 1 deletions

View file

@ -52,7 +52,8 @@ defmodule Pleroma.Web.AdminAPI.Config do
{:mime, :types},
{:cors_plug, [:max_age, :methods, :expose, :headers]},
{:auto_linker, :opts},
{:swarm, :node_blacklist}
{:swarm, :node_blacklist},
{:logger, :backends}
]
defp only_full_update?(%Config{} = config) do

View file

@ -2204,6 +2204,42 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
}
end
test "saving full setting if value is in full_key_update list", %{conn: conn} do
backends = Application.get_env(:logger, :backends)
on_exit(fn -> Application.put_env(:logger, :backends, backends) end)
config =
insert(:config,
group: ":logger",
key: ":backends",
value: :erlang.term_to_binary([])
)
conn =
post(conn, "/api/pleroma/admin/config", %{
configs: [
%{group: config.group, key: config.key, value: [":console"]}
]
})
assert json_response(conn, 200) == %{
"configs" => [
%{
"group" => ":logger",
"key" => ":backends",
"value" => [":console"]
}
]
}
assert Application.get_env(:logger, :backends) == [:console]
ExUnit.CaptureLog.capture_log(fn ->
require Logger
Logger.warn("Ooops...")
end) =~ "Ooops..."
end
test "saving full setting if value is not keyword", %{conn: conn} do
config =
insert(:config,