fixes for logger backends
authorAlexander <alex.strizhakov@gmail.com>
Sat, 21 Dec 2019 10:54:22 +0000 (13:54 +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
test/web/admin_api/config_test.exs

index a8a698c89352d4a87c2d159ae73a227c2d9cc2bf..ef658e0793b120503302fc04a9dfa92010ed2d57 100644 (file)
@@ -295,7 +295,8 @@ defmodule Pleroma.Web.AdminAPI.Config do
 
   @spec is_module_name?(String.t()) :: boolean()
   def is_module_name?(string) do
-    Regex.match?(~r/^(Pleroma|Phoenix|Tesla)\./, string) or string in ["Oban", "Ueberauth"]
+    Regex.match?(~r/^(Pleroma|Phoenix|Tesla|Quack)\./, string) or
+      string in ["Oban", "Ueberauth", "ExSyslogger"]
   end
 
   defp do_eval(entity) do
index 56a3a3a976d0af2f4f72641be0ce1c56755d5f49..ea3c43158904a4a6d13f6de8f1754f583c4b73e5 100644 (file)
@@ -2218,7 +2218,11 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
       conn =
         post(conn, "/api/pleroma/admin/config", %{
           configs: [
-            %{group: config.group, key: config.key, value: [":console"]}
+            %{
+              group: config.group,
+              key: config.key,
+              value: [":console", %{"tuple" => ["ExSyslogger", ":ex_syslogger"]}]
+            }
           ]
         })
 
@@ -2227,12 +2231,18 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
                  %{
                    "group" => ":logger",
                    "key" => ":backends",
-                   "value" => [":console"]
+                   "value" => [
+                     ":console",
+                     %{"tuple" => ["ExSyslogger", ":ex_syslogger"]}
+                   ]
                  }
                ]
              }
 
-      assert Application.get_env(:logger, :backends) == [:console]
+      assert Application.get_env(:logger, :backends) == [
+               :console,
+               {ExSyslogger, :ex_syslogger}
+             ]
 
       ExUnit.CaptureLog.capture_log(fn ->
         require Logger
index b8b1b01304f1635587a3fcb5ea33abc3f9f8c5d2..4f96322af1834201c53efa65c2f929b08f6070be 100644 (file)
@@ -175,6 +175,18 @@ defmodule Pleroma.Web.AdminAPI.ConfigTest do
       assert Config.from_binary(binary) == Tesla.Adapter.Hackney
     end
 
+    test "ExSyslogger module" do
+      binary = Config.transform("ExSyslogger")
+      assert binary == :erlang.term_to_binary(ExSyslogger)
+      assert Config.from_binary(binary) == ExSyslogger
+    end
+
+    test "Quack.Logger module" do
+      binary = Config.transform("Quack.Logger")
+      assert binary == :erlang.term_to_binary(Quack.Logger)
+      assert Config.from_binary(binary) == Quack.Logger
+    end
+
     test "sigil" do
       binary = Config.transform("~r[comp[lL][aA][iI][nN]er]")
       assert binary == :erlang.term_to_binary(~r/comp[lL][aA][iI][nN]er/)