1
0
mirror of https://git.pleroma.social/sjw/pleroma.git synced 2024-11-16 12:26:13 +01:00

fixes for logger backends

This commit is contained in:
Alexander 2019-12-21 13:54:22 +03:00 committed by Alexander Strizhakov
parent cda2c1fc63
commit 9c1f3bfeff
No known key found for this signature in database
GPG Key ID: 022896A53AEF1381
3 changed files with 27 additions and 4 deletions

View 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

View 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

View 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/)