Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow logger level configuration #1700

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
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