Skip to content

Commit

Permalink
feat: allow logger level configuration (#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
vatanasov committed Mar 18, 2024
1 parent db4f45d commit 75d945e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion config/runtime.exs
Expand Up @@ -42,6 +42,26 @@ if env != :test do
]
end

# Logging

log_level =
case System.get_env("LOG_LEVEL") do
"emergency" -> :emergency
"alert" -> :alert
"critical" -> :critical
"error" -> :error
"warning" -> :warning
"notice" -> :notice
"info" -> :info
"debug" -> :debug
_ -> nil
end

if not is_nil(log_level) do
config :logger,
level: log_level
end

if env in [:test, :prod] do
if System.get_env("ENABLE_TELEMETRY", "false") in ["true", "1"] do
{:ok, hostname} = :inet.gethostname()
Expand All @@ -57,7 +77,7 @@ if env in [:test, :prod] do

if System.get_env("ENABLE_JSON_LOG", "false") in ["true", "1"] do
config :logger,
level: :info,
level: log_level || :info,
backends: [LoggerJSON]

formatter = System.get_env("JSON_LOG_FORMAT", "datadog")
Expand Down

0 comments on commit 75d945e

Please sign in to comment.