From 063ab6d9115ec17bd1907d42a998f335a0cd69c9 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 19 Dec 2019 10:19:56 +0300 Subject: [PATCH] logger backends fix --- lib/pleroma/web/admin_api/config.ex | 3 +- .../admin_api/admin_api_controller_test.exs | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/admin_api/config.ex b/lib/pleroma/web/admin_api/config.ex index acc5a5183..a8a698c89 100644 --- a/lib/pleroma/web/admin_api/config.ex +++ b/lib/pleroma/web/admin_api/config.ex @@ -52,7 +52,8 @@ def update(%Config{} = config, %{value: value}) 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 diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs index 06b3266c1..56a3a3a97 100644 --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@ -2204,6 +2204,42 @@ test "saving config with partial update", %{conn: conn} 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,