Skip to content

Commit

Permalink
removes logger dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
zemuldo committed Oct 29, 2023
1 parent abfcf03 commit f1f3cb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 1 addition & 9 deletions lib/ex_secrets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ defmodule ExSecrets do
def get(key, provider) do
m = "ExSecrets.get(key, provider) is deprecated. Use ExSecrets.get/2 with options."

cond do
has_fun?(Logger, :warn) -> Logger.warn(m)
has_fun?(Logger, :warning) -> Logger.warning(m)
true -> :ok
end
IO.puts("#{IO.ANSI.yellow()}ExSecrets Warning ==> #{NaiveDateTime.utc_now()} ==> #{m}")

get(key, provider: provider)
end
Expand Down Expand Up @@ -208,8 +204,4 @@ defmodule ExSecrets do
ExSecrets.Application.get_providers() |> Enum.each(&Kernel.apply(&1, :reset, []))
:ok
end

defp has_fun?(module, func) do
Keyword.has_key?(module.__info__(:functions), func)
end
end
10 changes: 8 additions & 2 deletions lib/utils/secret_fetch_limiter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,20 @@ defmodule ExSecrets.Utils.SecretFetchLimiter do
Kernel.apply(module, function, args)

:warn ->
Logger.warn("Fetch secret #{key} reached limit #{limit}")
IO.puts(
"#{IO.ANSI.yellow()}ExSecrets Warning ==> #{NaiveDateTime.utc_now()} ==> Fetch secret #{key} reached limit #{limit}"
)

Kernel.apply(module, function, args)

:raise ->
raise "Fetch secret #{key} reached limit #{limit}"

_ ->
Logger.error("Fetch secret #{key} reached limit #{limit}")
IO.puts(
"#{IO.ANSI.red()}ExSecrets Warning ==> #{NaiveDateTime.utc_now()} ==> Fetch secret #{key} reached limit #{limit}"
)

Kernel.apply(module, function, args)
end
end
Expand Down

0 comments on commit f1f3cb5

Please sign in to comment.