Skip to content

Commit

Permalink
fix remove deprecated Logger.warn/2 calls (#207)
Browse files Browse the repository at this point in the history
* fix remove deprecated `Logger.warn/2` calls

* format
  • Loading branch information
aleagnelli authored Aug 29, 2023
1 parent 454fd45 commit e072914
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule WebApp.RandomWorkGenerator do
end

def handle_info(error, state) do
Logger.warn("Failed to enqueue Oban work: #{inspect(error)}")
Logger.warning("Failed to enqueue Oban work: #{inspect(error)}")

{:noreply, state}
end
Expand Down
4 changes: 2 additions & 2 deletions example_applications/web_app/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule WebApp.MixProject do
[
app: :web_app,
version: "0.1.0",
elixir: "~> 1.7",
elixir: "~> 1.11",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
Expand Down Expand Up @@ -48,7 +48,7 @@ defmodule WebApp.MixProject do
{:plug_cowboy, "~> 2.0"},
{:faker, "~> 0.16"},
{:oban, "~> 2.9.0"},
{:broadway, "~> 1.0.0"},
{:broadway, "~> 1.0.2"},
{:dialyxir, "~> 1.0", only: :dev, runtime: false},
# {:prom_ex, "~> 1.5.0"}
{:prom_ex, path: "../../"}
Expand Down
16 changes: 9 additions & 7 deletions example_applications/web_app/mix.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%{
"broadway": {:hex, :broadway, "1.0.1", "7b4ca0b439a425730b5fc1bf06aae350df6171434fd4f29bdbbe50d2d9d518fb", [:mix], [{:gen_stage, "~> 1.0", [hex: :gen_stage, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.3.7", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6d1c7fdc100ba484a477c42881553dfa1730f31c461308286132efbfeb85568f"},
"castore": {:hex, :castore, "0.1.14", "3f6d7c7c1574c402fef29559d3f1a7389ba3524bc6a090a5e9e6abc3af65dcca", [:mix], [], "hexpm", "b34af542eadb727e6c8b37fdf73e18b2e02eb483a4ea0b52fd500bc23f052b7b"},
"broadway": {:hex, :broadway, "1.0.7", "7808f9e3eb6f53ca6d060f0f9d61012dd8feb0d7a82e62d087dd517b9b66fa53", [:mix], [{:gen_stage, "~> 1.0", [hex: :gen_stage, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.3.7 or ~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e76cfb0a7d64176c387b8b1ddbfb023e2ee8a63e92f43664d78e6d5d0b1177c6"},
"castore": {:hex, :castore, "1.0.3", "7130ba6d24c8424014194676d608cb989f62ef8039efd50ff4b3f33286d06db8", [:mix], [], "hexpm", "680ab01ef5d15b161ed6a95449fac5c6b8f60055677a8e79acf01b27baa4390b"},
"connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"},
"cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
Expand All @@ -13,17 +13,19 @@
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"faker": {:hex, :faker, "0.17.0", "671019d0652f63aefd8723b72167ecdb284baf7d47ad3a82a15e9b8a6df5d1fa", [:mix], [], "hexpm", "a7d4ad84a93fd25c5f5303510753789fc2433ff241bf3b4144d3f6f291658a6a"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"finch": {:hex, :finch, "0.9.0", "8b772324aebafcaba763f1dffaa3e7f52f8c4e52485f50f48bbb2f42219a2e87", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.3.5", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a93bfcad9ca50fa3cb2d459f27667d9a87cfbb7fecf9b29b2e78a50bc2ab445d"},
"finch": {:hex, :finch, "0.16.0", "40733f02c89f94a112518071c0a91fe86069560f5dbdb39f9150042f44dcfb1a", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6 or ~> 1.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "f660174c4d519e5fec629016054d60edd822cdfe2b7270836739ac2f97735ec5"},
"floki": {:hex, :floki, "0.32.0", "f915dc15258bc997d49be1f5ef7d3992f8834d6f5695270acad17b41f5bcc8e2", [:mix], [{:html_entities, "~> 0.5.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm", "1c5a91cae1fd8931c26a4826b5e2372c284813904c8bacb468b5de39c7ececbd"},
"gen_stage": {:hex, :gen_stage, "1.1.2", "b1656cd4ba431ed02c5656fe10cb5423820847113a07218da68eae5d6a260c23", [:mix], [], "hexpm", "9e39af23140f704e2b07a3e29d8f05fd21c2aaf4088ff43cb82be4b9e3148d02"},
"gen_stage": {:hex, :gen_stage, "1.2.1", "19d8b5e9a5996d813b8245338a28246307fd8b9c99d1237de199d21efc4c76a1", [:mix], [], "hexpm", "83e8be657fa05b992ffa6ac1e3af6d57aa50aace8f691fcf696ff02f8335b001"},
"gettext": {:hex, :gettext, "0.19.0", "6909d61b38bb33339558f128f8af5913d5d5fe304a770217bf352b1620fb7ec4", [:mix], [], "hexpm", "3f7a274f52ebda9bb6655dfeda3d6b0dc4537ae51ce41dcccc7f73ca7379ad5e"},
"hpax": {:hex, :hpax, "0.1.2", "09a75600d9d8bbd064cdd741f21fc06fc1f4cf3d0fcc335e5aa19be1a7235c84", [:mix], [], "hexpm", "2c87843d5a23f5f16748ebe77969880e29809580efdaccd615cd3bed628a8c13"},
"html_entities": {:hex, :html_entities, "0.5.2", "9e47e70598da7de2a9ff6af8758399251db6dbb7eebe2b013f2bbd2515895c3c", [:mix], [], "hexpm", "c53ba390403485615623b9531e97696f076ed415e8d8058b1dbaa28181f4fdcc"},
"jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"},
"mime": {:hex, :mime, "2.0.2", "0b9e1a4c840eafb68d820b0e2158ef5c49385d17fb36855ac6e7e087d4b1dcc5", [:mix], [], "hexpm", "e6a3f76b4c277739e36c2e21a2c640778ba4c3846189d5ab19f97f126df5f9b7"},
"mint": {:hex, :mint, "1.4.0", "cd7d2451b201fc8e4a8fd86257fb3878d9e3752899eb67b0c5b25b180bde1212", [:mix], [{:castore, "~> 0.1.0", [hex: :castore, repo: "hexpm", optional: true]}], "hexpm", "10a99e144b815cbf8522dccbc8199d15802440fc7a64d67b6853adb6fa170217"},
"nimble_options": {:hex, :nimble_options, "0.3.7", "1e52dd7673d36138b1a5dede183b5d86dff175dc46d104a8e98e396b85b04670", [:mix], [], "hexpm", "2086907e6665c6b6579be54ef5001928df5231f355f71ed258f80a55e9f63633"},
"nimble_pool": {:hex, :nimble_pool, "0.2.4", "1db8e9f8a53d967d595e0b32a17030cdb6c0dc4a451b8ac787bf601d3f7704c3", [:mix], [], "hexpm", "367e8071e137b787764e6a9992ccb57b276dc2282535f767a07d881951ebeac6"},
"mint": {:hex, :mint, "1.5.1", "8db5239e56738552d85af398798c80648db0e90f343c8469f6c6d8898944fb6f", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "4a63e1e76a7c3956abd2c72f370a0d0aecddc3976dea5c27eccbecfa5e7d5b1e"},
"nimble_options": {:hex, :nimble_options, "1.0.2", "92098a74df0072ff37d0c12ace58574d26880e522c22801437151a159392270e", [:mix], [], "hexpm", "fd12a8db2021036ce12a309f26f564ec367373265b53e25403f0ee697380f1b8"},
"nimble_pool": {:hex, :nimble_pool, "1.0.0", "5eb82705d138f4dd4423f69ceb19ac667b3b492ae570c9f5c900bb3d2f50a847", [:mix], [], "hexpm", "80be3b882d2d351882256087078e1b1952a28bf98d0a287be87e4a24a710b67a"},
"oban": {:hex, :oban, "2.9.2", "5504c1c28d0b04e326c1075bd5f0f9c0fbe93850f581d9b201e2e2ad86ef8cc8", [:mix], [{:ecto_sql, ">= 3.4.3", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "f05a042c6611c013a21717dd78cc1e64690b6b66885e6e237c3a2af1b9e9cff8"},
"octo_fetch": {:hex, :octo_fetch, "0.3.0", "89ff501d2ac0448556ff1931634a538fe6d6cd358ba827ce1747e6a42a46efbf", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "c07e44f2214ab153743b7b3182f380798d0b294b1f283811c1e30cff64096d3d"},
"phoenix": {:hex, :phoenix, "1.6.5", "07af307b28a5820b4394f27ac7003df052e065ff651520a58abb16be1eecd519", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "97dc3052ca648499280e0636471f1d0439fc623ccdce27d2d8135651421ee80c"},
"phoenix_ecto": {:hex, :phoenix_ecto, "4.4.0", "0672ed4e4808b3fbed494dded89958e22fb882de47a97634c0b13e7b0b5f7720", [:mix], [{:ecto, "~> 3.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "09864e558ed31ee00bd48fcc1d4fc58ae9678c9e81649075431e69dbabb43cc1"},
"phoenix_html": {:hex, :phoenix_html, "3.0.4", "232d41884fe6a9c42d09f48397c175cd6f0d443aaa34c7424da47604201df2e1", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "ce17fd3cf815b2ed874114073e743507704b1f5288bb03c304a77458485efc8b"},
Expand Down
2 changes: 1 addition & 1 deletion guides/howtos/Telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ doing the following:
"my-handler-2",
[:my_cool_app, :accounts, :new_user, :error],
fn _event_name, _event_measurement, event_metadata, _config ->
Logger.warn("User failed to register: #{inspect(event_metadata)}")
Logger.warning("User failed to register: #{inspect(event_metadata)}")
end,
%{}
)
Expand Down
4 changes: 3 additions & 1 deletion lib/prom_ex/dashboard_uploader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ defmodule PromEx.DashboardUploader do
Logger.info("PromEx.DashboardUploader successfully uploaded #{full_dashboard_path} to Grafana.")

{:error, reason} ->
Logger.warn("PromEx.DashboardUploader failed to upload #{full_dashboard_path} to Grafana: #{inspect(reason)}")
Logger.warning(
"PromEx.DashboardUploader failed to upload #{full_dashboard_path} to Grafana: #{inspect(reason)}"
)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/prom_ex/grafana_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ defmodule PromEx.GrafanaClient do
{:ok, Jason.decode!(body)}

{:ok, %Finch.Response{status: status_code} = response} ->
Logger.warn("Received a #{status_code} from Grafana because: #{inspect(response)}")
Logger.warning("Received a #{status_code} from Grafana because: #{inspect(response)}")
{:error, lookup_status_code(status_code)}

{:error, %Mint.TransportError{} = mint_error_reason} ->
{:error, Exception.message(mint_error_reason)}

unknown_response ->
Logger.warn("Received an unhandled response from Grafana because: #{inspect(unknown_response)}")
Logger.warning("Received an unhandled response from Grafana because: #{inspect(unknown_response)}")

{:error, :unkown}
end
Expand Down
4 changes: 2 additions & 2 deletions lib/prom_ex/lifecycle_annotator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ defmodule PromEx.LifecycleAnnotator do
Logger.info("PromEx.LifecycleAnnotator successfully created start annotation in Grafana.")

{:error, reason} ->
Logger.warn("PromEx.LifecycleAnnotator failed to create start annotation in Grafana: #{inspect(reason)}")
Logger.warning("PromEx.LifecycleAnnotator failed to create start annotation in Grafana: #{inspect(reason)}")
end

{:noreply, state}
Expand All @@ -107,7 +107,7 @@ defmodule PromEx.LifecycleAnnotator do
Logger.info("PromEx.LifecycleAnnotator successfully created stop annotation in Grafana.")

{:error, reason} ->
Logger.warn("PromEx.LifecycleAnnotator failed to create stop annotation in Grafana: #{inspect(reason)}")
Logger.warning("PromEx.LifecycleAnnotator failed to create stop annotation in Grafana: #{inspect(reason)}")
end

:ok
Expand Down
2 changes: 1 addition & 1 deletion lib/prom_ex/metrics_server/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule PromEx.MetricsServer.Plug do
def call(%Conn{request_path: path} = conn, {:none, %{path: path, prom_ex_module: prom_ex_module}}) do
case PromEx.get_metrics(prom_ex_module) do
:prom_ex_down ->
Logger.warn("Attempted to fetch metrics from #{prom_ex_module}, but the module has not been initialized")
Logger.warning("Attempted to fetch metrics from #{prom_ex_module}, but the module has not been initialized")

conn
|> put_resp_content_type("text/plain")
Expand Down
2 changes: 1 addition & 1 deletion lib/prom_ex/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ defmodule PromEx.Plug do
def call(%Conn{request_path: metrics_path} = conn, %{metrics_path: metrics_path, prom_ex_module: prom_ex_module}) do
case PromEx.get_metrics(prom_ex_module) do
:prom_ex_down ->
Logger.warn("Attempted to fetch metrics from #{prom_ex_module}, but the module has not been initialized")
Logger.warning("Attempted to fetch metrics from #{prom_ex_module}, but the module has not been initialized")

conn
|> put_resp_content_type("text/plain")
Expand Down
2 changes: 1 addition & 1 deletion lib/prom_ex/plugins/plug_cowboy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ if Code.ensure_loaded?(Plug.Cowboy) do
}

nil ->
Logger.warn("Cowboy failed to provide valid response status #{inspect(resp_status)}")
Logger.warning("Cowboy failed to provide valid response status #{inspect(resp_status)}")
%{}
end
end
Expand Down

0 comments on commit e072914

Please sign in to comment.