diff --git a/lib/x509/test/crl_server.ex b/lib/x509/test/crl_server.ex index 74ea3e9..4522af7 100644 --- a/lib/x509/test/crl_server.ex +++ b/lib/x509/test/crl_server.ex @@ -3,7 +3,6 @@ defmodule X509.Test.CRLServer do Simple CRL responder for use in test suites. """ use GenServer - require Logger @doc """ Starts a CRL responder. @@ -107,7 +106,7 @@ defmodule X509.Test.CRLServer do {:ok, :http_eoh} -> case Map.get(crl_map, path) do nil -> - Logger.warn("No CRL defined for #{path}") + X509.Util.warn("No CRL defined for #{path}") respond(socket, 404) :gen_tcp.close(socket) diff --git a/lib/x509/test/suite.ex b/lib/x509/test/suite.ex index 35c6bf3..6c24060 100644 --- a/lib/x509/test/suite.ex +++ b/lib/x509/test/suite.ex @@ -63,8 +63,6 @@ defmodule X509.Test.Suite do * `client-cert` - requires that the client present a valid certificate """ - require Logger - defstruct [ :domain, :key_type, @@ -582,7 +580,7 @@ defmodule X509.Test.Suite do %__MODULE__{valid: valid, chain: chain, server_key: server_key}, scenario ) do - Logger.warn("Unknown scenario: #{scenario}") + X509.Util.warn("Unknown scenario: #{scenario}") [ cert: X509.Certificate.to_der(valid), diff --git a/lib/x509/util.ex b/lib/x509/util.ex index 7497df2..5d218e3 100644 --- a/lib/x509/util.ex +++ b/lib/x509/util.ex @@ -1,6 +1,8 @@ defmodule X509.Util do @moduledoc false + require Logger + def app_version(application) do application |> Application.spec() @@ -9,4 +11,16 @@ defmodule X509.Util do |> String.split(".") |> Enum.map(&String.to_integer/1) end + + # Create a utility function that handles checking for the + # existence of Logger.warning/2 if not fallback to Logger.warn/2 + if macro_exported?(Logger, :warning, 2) do + def warn(message, metadata \\ []) do + Logger.warning(message, metadata) + end + else + def warn(message, metadata \\ []) do + Logger.warn(message, metadata) + end + end end diff --git a/test/x509/test/server_test.exs b/test/x509/test/server_test.exs index 2433a08..394887b 100644 --- a/test/x509/test/server_test.exs +++ b/test/x509/test/server_test.exs @@ -25,7 +25,6 @@ defmodule X509.Test.ServerTest do use ExUnit.Case import X509.TestHelper - require Logger # # Client under test @@ -839,7 +838,7 @@ defmodule X509.Test.ServerTest do end end else - Logger.warn("ECDSA certificates can't be tested on the current OTP version") + X509.Util.warn("ECDSA certificates can't be tested on the current OTP version") end #