Skip to content

Commit c4e0e54

Browse files
Merge pull request #1408 from OpenFn/log_level_changes
Validate LOG_LEVEL and set ecto log level to debug
2 parents 72d1d9a + 7237e24 commit c4e0e54

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

config/config.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import Config
1010
config :lightning,
1111
ecto_repos: [Lightning.Repo]
1212

13-
config :lightning, Lightning.Repo, types: Lightning.PostgrexTypes
13+
config :lightning, Lightning.Repo,
14+
types: Lightning.PostgrexTypes,
15+
log: :debug
1416

1517
config :hammer,
1618
backend:

config/runtime.exs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,16 @@ config :lightning, LightningWeb.Endpoint,
236236
]
237237

238238
if log_level = System.get_env("LOG_LEVEL") do
239-
config :logger, level: log_level |> String.to_atom()
239+
allowed_log_levels =
240+
~w[emergency alert critical error warning warn notice info debug]
241+
242+
if log_level in allowed_log_levels do
243+
config :logger, level: log_level |> String.to_atom()
244+
else
245+
raise """
246+
Invalid LOG_LEVEL, must be on of #{allowed_log_levels |> Enum.join(", ")}
247+
"""
248+
end
240249
end
241250

242251
if config_env() == :prod do

0 commit comments

Comments
 (0)