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

Update deprecated Logger.warn fn to Logger.warning #2

Merged
merged 2 commits into from
May 30, 2024
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
6 changes: 6 additions & 0 deletions lib/nerves_hub_link/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ defmodule NervesHubLink.Application do
}

children = [
{PropertyTable,
name: NervesHubLink,
properties: [
{["status"], :disconnected},
{["update_available"], nil}
]},
{UpdateManager, fwup_config},
Connection,
{Socket, config}
Expand Down
2 changes: 1 addition & 1 deletion lib/nerves_hub_link/certificate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ defmodule NervesHubLink.Certificate do
ca_store.ca_certs()

true ->
Logger.warn(
Logger.warning(
"[NervesHubLink] No CA store or :cacerts have been specified. Request will fail"
)

Expand Down
6 changes: 3 additions & 3 deletions lib/nerves_hub_link/client/default.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ defmodule NervesHubLink.Client.Default do
end

def handle_fwup_message({:warning, _, message}) do
Logger.warn("FWUP WARN: #{message}")
Logger.warning("FWUP WARN: #{message}")
end

def handle_fwup_message({:ok, status, message}) do
Logger.info("FWUP SUCCESS: #{status} #{message}")
end

def handle_fwup_message(fwup_message) do
Logger.warn("Unknown FWUP message: #{inspect(fwup_message)}")
Logger.warning("Unknown FWUP message: #{inspect(fwup_message)}")
end

@impl NervesHubLink.Client
def handle_error(error) do
Logger.warn("[NervesHubLink] error: #{inspect(error)}")
Logger.warning("[NervesHubLink] error: #{inspect(error)}")
end
end
3 changes: 3 additions & 0 deletions lib/nerves_hub_link/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ defmodule NervesHubLink.Connection do
"""
@spec connected() :: :ok
def connected() do
PropertyTable.put(NervesHubLink, ["status"], :connected)
Agent.update(__MODULE__, fn _ -> {:connected, current_time()} end)
end

Expand All @@ -103,6 +104,8 @@ defmodule NervesHubLink.Connection do
"""
@spec disconnected() :: :ok
def disconnected() do
PropertyTable.put(NervesHubLink, ["status"], :disconnected)

# If we are already in a disconnected state, then don't
# overwrite the existing value so we can measure from
# the first point of disconnect
Expand Down
15 changes: 10 additions & 5 deletions lib/nerves_hub_link/socket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ defmodule NervesHubLink.Socket do
# Device API messages
#
def handle_message(@device_topic, "reboot", _params, socket) do
Logger.warn("Reboot Request from NervesHubLink")
Logger.warning("Reboot Request from NervesHubLink")
_ = push(socket, @device_topic, "rebooting", %{})
# TODO: Maybe allow delayed reboot
Nerves.Runtime.reboot()
Expand All @@ -169,7 +169,7 @@ defmodule NervesHubLink.Socket do
# Console API messages
#
def handle_message(@console_topic, "restart", _payload, socket) do
Logger.warn("[#{inspect(__MODULE__)}] Restarting IEx process from web request")
Logger.warning("[#{inspect(__MODULE__)}] Restarting IEx process from web request")

_ = push(socket, @console_topic, "up", %{data: "\r*** Restarting IEx ***\r"})

Expand Down Expand Up @@ -209,7 +209,7 @@ defmodule NervesHubLink.Socket do
def handle_info({:EXIT, iex_pid, reason}, %{assigns: %{iex_pid: iex_pid}} = socket) do
msg = "\r******* Remote IEx stopped: #{inspect(reason)} *******\r"
_ = push(socket, @console_topic, "up", %{data: msg})
Logger.warn(msg)
Logger.warning(msg)

socket =
socket
Expand All @@ -235,7 +235,7 @@ defmodule NervesHubLink.Socket do
end

def handle_info(msg, socket) do
Logger.warn("[#{inspect(__MODULE__)}] Unhandled handle_info: #{inspect(msg)}")
Logger.warning("[#{inspect(__MODULE__)}] Unhandled handle_info: #{inspect(msg)}")
{:noreply, socket}
end

Expand All @@ -262,6 +262,8 @@ defmodule NervesHubLink.Socket do
end

defp handle_join_reply(%{"firmware_url" => url} = update) when is_binary(url) do
PropertyTable.put(NervesHubLink, ["update_available"], true)

case NervesHubLinkCommon.Message.UpdateInfo.parse(update) do
{:ok, %NervesHubLinkCommon.Message.UpdateInfo{} = info} ->
UpdateManager.apply_update(info)
Expand All @@ -272,7 +274,10 @@ defmodule NervesHubLink.Socket do
end
end

defp handle_join_reply(_), do: :noop
defp handle_join_reply(_) do
PropertyTable.put(NervesHubLink, ["update_available"], false)
:noop
end

defp maybe_join_console(socket) do
if socket.assigns.remote_iex do
Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ defmodule NervesHubLink.MixProject do
{:nerves_runtime, "~> 0.8"},
{:nerves_hub_link_common, "~> 0.4"},
{:nerves_hub_ca_store, "~> 1.0.0"},
{:property_table, "~> 0.2"},
{:slipstream, "~> 1.0 or ~> 0.8"},
{:x509, "~> 0.5"}
]
Expand Down