Skip to content

Commit

Permalink
Translate warn to warning for Elixir >= 1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
altjohndev committed Feb 6, 2024
1 parent de7e7a4 commit 5f396fe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/logger_json.ex
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ defmodule LoggerJSON do
defp put_env(env), do: Application.put_env(:logger_json, :backend, env)

defp meet_level?(_lvl, nil), do: true

if Version.match?(System.version(), ">= 1.11.0") do
# This clause avoids `IO.warn/1` being triggered by Logger when using `:warn`.
defp meet_level?(:warn, min), do: Logger.compare_levels(:warning, min) != :lt
end

defp meet_level?(lvl, min), do: Logger.compare_levels(lvl, min) != :lt

defp init(config, state) do
Expand Down

0 comments on commit 5f396fe

Please sign in to comment.