Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't warn on Logger.warn #69

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/x509/logger.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
defmodule X509.Logger do
@moduledoc false
alias X509.Util

require Logger

if Util.app_version(:logger) >= [1, 11, 0] do
def warn(message, metadata \\ []) do
Logger.warning(message, metadata)
end
else
def warn(message, metadata \\ []) do
Logger.warn(message, metadata)
end
end
end
2 changes: 1 addition & 1 deletion lib/x509/test/crl_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ defmodule X509.Test.CRLServer do
{:ok, :http_eoh} ->
case Map.get(crl_map, path) do
nil ->
X509.Util.warn("No CRL defined for #{path}")
X509.Logger.warn("No CRL defined for #{path}")
respond(socket, 404)
:gen_tcp.close(socket)

Expand Down
2 changes: 1 addition & 1 deletion lib/x509/test/suite.ex
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ defmodule X509.Test.Suite do
%__MODULE__{valid: valid, chain: chain, server_key: server_key},
scenario
) do
X509.Util.warn("Unknown scenario: #{scenario}")
X509.Logger.warn("Unknown scenario: #{scenario}")

[
cert: X509.Certificate.to_der(valid),
Expand Down
14 changes: 0 additions & 14 deletions lib/x509/util.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
defmodule X509.Util do
@moduledoc false

require Logger

def app_version(application) do
application
|> Application.spec()
Expand All @@ -11,16 +9,4 @@ 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
2 changes: 1 addition & 1 deletion test/x509/test/server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@
end
end
else
X509.Util.warn("ECDSA certificates can't be tested on the current OTP version")
X509.Logger.warn("ECDSA certificates can't be tested on the current OTP version")
end

#
Expand Down Expand Up @@ -897,7 +897,7 @@
defp create_pem_files(context) do
tmp_dir =
System.tmp_dir!()
|> Path.join("x509_server_test#{System.get_pid()}")

Check warning on line 900 in test/x509/test/server_test.exs

View workflow job for this annotation

GitHub Actions / test (1.13.4, 25.0)

System.get_pid/0 is deprecated. Use System.pid/0 instead

Check warning on line 900 in test/x509/test/server_test.exs

View workflow job for this annotation

GitHub Actions / test (1.14.3, 25.3)

System.get_pid/0 is deprecated. Use System.pid/0 instead

Check warning on line 900 in test/x509/test/server_test.exs

View workflow job for this annotation

GitHub Actions / test (1.15.1, 26.0.2)

System.get_pid/0 is deprecated. Use System.pid/0 instead

File.mkdir(tmp_dir)

Expand Down
Loading