From f1f3cb5091a6ef9129476799809e6e7a5073b2c4 Mon Sep 17 00:00:00 2001 From: Zemuldo Date: Mon, 30 Oct 2023 00:51:45 +0300 Subject: [PATCH] removes logger dependency --- lib/ex_secrets.ex | 10 +--------- lib/utils/secret_fetch_limiter.ex | 10 ++++++++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/ex_secrets.ex b/lib/ex_secrets.ex index e61230b..c1fb495 100644 --- a/lib/ex_secrets.ex +++ b/lib/ex_secrets.ex @@ -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 @@ -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 diff --git a/lib/utils/secret_fetch_limiter.ex b/lib/utils/secret_fetch_limiter.ex index f22a00f..f54ccbf 100644 --- a/lib/utils/secret_fetch_limiter.ex +++ b/lib/utils/secret_fetch_limiter.ex @@ -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