Skip to content

Commit

Permalink
Merge pull request #1408 from OpenFn/log_level_changes
Browse files Browse the repository at this point in the history
Validate LOG_LEVEL and set ecto log level to debug
  • Loading branch information
taylordowns2000 authored Nov 20, 2023
2 parents 72d1d9a + 7237e24 commit c4e0e54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import Config
config :lightning,
ecto_repos: [Lightning.Repo]

config :lightning, Lightning.Repo, types: Lightning.PostgrexTypes
config :lightning, Lightning.Repo,
types: Lightning.PostgrexTypes,
log: :debug

config :hammer,
backend:
Expand Down
11 changes: 10 additions & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,16 @@ config :lightning, LightningWeb.Endpoint,
]

if log_level = System.get_env("LOG_LEVEL") do
config :logger, level: log_level |> String.to_atom()
allowed_log_levels =
~w[emergency alert critical error warning warn notice info debug]

if log_level in allowed_log_levels do
config :logger, level: log_level |> String.to_atom()
else
raise """
Invalid LOG_LEVEL, must be on of #{allowed_log_levels |> Enum.join(", ")}
"""
end
end

if config_env() == :prod do
Expand Down

0 comments on commit c4e0e54

Please sign in to comment.