logger backends fix
authorAlexander <alex.strizhakov@gmail.com>
Thu, 19 Dec 2019 07:19:56 +0000 (10:19 +0300)
committerAlexander Strizhakov <alex.strizhakov@gmail.com>
Fri, 10 Jan 2020 12:52:01 +0000 (15:52 +0300)
lib/pleroma/web/admin_api/config.ex
test/web/admin_api/admin_api_controller_test.exs

index acc5a51830856818d886d621f661d8542e997d4f..a8a698c89352d4a87c2d159ae73a227c2d9cc2bf 100644 (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
index 06b3266c14880e88f35f05fbc65edefe864a5ddd..56a3a3a976d0af2f4f72641be0ce1c56755d5f49 100644 (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,