feat(docker): allow to configure loglevel at runtime through env variable
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user