forked from potsda.mn/mobilizon
feat(docker): allow to configure loglevel at runtime through env variable
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
9907f887c9
commit
4855af8f87
|
@ -2,6 +2,26 @@
|
|||
|
||||
import Config
|
||||
|
||||
loglevels = [
|
||||
:emergency,
|
||||
:alert,
|
||||
:critical,
|
||||
:error,
|
||||
:warning,
|
||||
:notice,
|
||||
:info,
|
||||
:debug
|
||||
]
|
||||
|
||||
loglevel_env = System.get_env("MOBILIZON_LOGLEVEL", "error")
|
||||
|
||||
loglevel =
|
||||
if loglevel_env in Enum.map(loglevels, &to_string/1) do
|
||||
String.to_existing_atom(loglevel_env)
|
||||
else
|
||||
:error
|
||||
end
|
||||
|
||||
listen_ip = System.get_env("MOBILIZON_INSTANCE_LISTEN_IP", "0.0.0.0")
|
||||
|
||||
listen_ip =
|
||||
|
@ -43,6 +63,8 @@ config :mobilizon, Mobilizon.Storage.Repo,
|
|||
ssl: System.get_env("MOBILIZON_DATABASE_SSL", "false") == "true",
|
||||
pool_size: 10
|
||||
|
||||
config :logger, level: loglevel
|
||||
|
||||
config :mobilizon, Mobilizon.Web.Email.Mailer,
|
||||
adapter: Swoosh.Adapters.SMTP,
|
||||
relay: System.get_env("MOBILIZON_SMTP_SERVER", "localhost"),
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule Mix.Tasks.Mobilizon.Common do
|
|||
if mix_task?(), do: Mix.Task.run("app.config")
|
||||
|
||||
unless System.get_env("DEBUG") || @env == :test do
|
||||
Logger.configure(level: :error)
|
||||
Logger.configure(level: loglevel())
|
||||
end
|
||||
|
||||
Application.put_env(:phoenix, :serve_endpoints, false, persistent: true)
|
||||
|
@ -144,4 +144,25 @@ defmodule Mix.Tasks.Mobilizon.Common do
|
|||
defp format_name("Elixir.Mix.Tasks.Mobilizon." <> task_name) do
|
||||
String.downcase(task_name)
|
||||
end
|
||||
|
||||
@loglevels [
|
||||
:emergency,
|
||||
:alert,
|
||||
:critical,
|
||||
:error,
|
||||
:warning,
|
||||
:notice,
|
||||
:info,
|
||||
:debug
|
||||
]
|
||||
|
||||
defp loglevel do
|
||||
loglevel_env = System.get_env("MOBILIZON_LOGLEVEL", "error")
|
||||
|
||||
if loglevel_env in Enum.map(@loglevels, &to_string/1) do
|
||||
String.to_existing_atom(loglevel_env)
|
||||
else
|
||||
:error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue