Skip to content

Commit

Permalink
#19 Demote non safety-critical info/warn log messages to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
robinhilliard committed May 20, 2021
1 parent a992b11 commit 748aaa6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions lib/mavlink/frame.ex
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ defmodule MAVLink.Frame do
end
rescue
_ ->
:ok = Logger.warn Logger.warn("validate_and_unpack: Failed to unpack #{inspect(frame)}, couldn't match payload")
:ok = Logger.debug("validate_and_unpack: Failed to unpack #{inspect(frame)}, couldn't match payload")
:failed_to_unpack
end
else
:ok = Logger.warn("validate_and_unpack: Checksum invalid #{inspect(frame)}")
:ok = Logger.debug("validate_and_unpack: Checksum invalid #{inspect(frame)}")
:checksum_invalid
end
_ ->
:ok = Logger.warn("validate_and_unpack: Unknown message #{inspect(frame)}")
:ok = Logger.debug("validate_and_unpack: Unknown message #{inspect(frame)}")
:unknown_message
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/mavlink/local_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ defmodule MAVLink.LocalConnection do
:local,
case Agent.start(fn -> [] end, name: MAVLink.SubscriptionCache) do
{:ok, _} ->
:ok = Logger.info("Started Subscription Cache")
:ok = Logger.debug("Started Subscription Cache")
local_connection # No subscriptions to restore
{:error, {:already_started, _}} ->
:ok = Logger.info("Restoring subscriptions from Subscription Cache")
:ok = Logger.debug("Restoring subscriptions from Subscription Cache")
reduce(
Agent.get(MAVLink.SubscriptionCache, fn subs -> subs end),
local_connection,
Expand Down Expand Up @@ -109,7 +109,7 @@ defmodule MAVLink.LocalConnection do

# Subscription request from subscriber
def subscribe(query, pid, local_connection) do
:ok = Logger.info("Subscribe #{inspect(pid)} to query #{inspect(query)}")
:ok = Logger.debug("Subscribe #{inspect(pid)} to query #{inspect(query)}")
# Monitor so that we can unsubscribe dead processes
Process.monitor(pid)
# Uniq prevents duplicate subscriptions
Expand All @@ -125,7 +125,7 @@ defmodule MAVLink.LocalConnection do

# Unsubscribe request from subscriber
def unsubscribe(pid, local_connection) do
:ok = Logger.info("Unsubscribe #{inspect(pid)}")
:ok = Logger.debug("Unsubscribe #{inspect(pid)}")
%LocalConnection{
local_connection | subscriptions:
(
Expand All @@ -138,7 +138,7 @@ defmodule MAVLink.LocalConnection do

# Automatically unsubscribe a dead subscriber process
def subscriber_down(pid, local_connection) do
:ok = Logger.info("Subscriber #{inspect(pid)} exited")
:ok = Logger.debug("Subscriber #{inspect(pid)} exited")
%LocalConnection{
local_connection | subscriptions:
(
Expand All @@ -150,7 +150,7 @@ defmodule MAVLink.LocalConnection do


defp update_subscription_cache(subscriptions) do
:ok = Logger.info("Update subscription cache: #{inspect(subscriptions)}")
:ok = Logger.debug("Update subscription cache: #{inspect(subscriptions)}")
Agent.update(MAVLink.SubscriptionCache, fn _ -> subscriptions end)
subscriptions
end
Expand Down
6 changes: 3 additions & 3 deletions lib/mavlink/serial_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defmodule MAVLink.SerialConnection do
:not_a_frame ->
# Noise or malformed frame
if byte_size(buffer) + byte_size(raw) > 0 do
:ok = Logger.warn("SerialConnection.handle_info: Not a frame: #{inspect(buffer <> raw)}")
:ok = Logger.debug("SerialConnection.handle_info: Not a frame: #{inspect(buffer <> raw)}")
end
{:error, :not_a_frame, port, struct(receiving_connection, [buffer: <<>>])}
{nil, rest} ->
Expand All @@ -43,10 +43,10 @@ defmodule MAVLink.SerialConnection do
{:ok, port, struct(receiving_connection, [buffer: rest]), valid_frame}
:unknown_message ->
# We re-broadcast valid frames with unknown messages
:ok = Logger.warn "rebroadcasting unknown message with id #{received_frame.message_id}}"
:ok = Logger.debug "rebroadcasting unknown message with id #{received_frame.message_id}}"
{:ok, port, struct(receiving_connection, [buffer: rest]), struct(received_frame, [target: :broadcast])}
reason ->
:ok = Logger.warn(
:ok = Logger.debug(
"SerialConnection.handle_info: frame received failed: #{Atom.to_string(reason)}")
{:error, reason, port, struct(receiving_connection, [buffer: rest])}
end
Expand Down
10 changes: 5 additions & 5 deletions lib/mavlink/tcp_out_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule MAVLink.TCPOutConnection do
:not_a_frame ->
# Noise or malformed frame
if byte_size(buffer) + byte_size(raw) > 0 do
:ok = Logger.warn("TCPOutConnection.handle_info: Not a frame #{inspect(buffer <> raw)}")
:ok = Logger.debug("TCPOutConnection.handle_info: Not a frame #{inspect(buffer <> raw)}")
end
{:error, :not_a_frame, socket, struct(receiving_connection, [buffer: <<>>])}
{nil, rest} ->
Expand All @@ -34,10 +34,10 @@ defmodule MAVLink.TCPOutConnection do
{:ok, socket, struct(receiving_connection, [buffer: rest]), valid_frame}
:unknown_message ->
# We re-broadcast valid frames with unknown messages
:ok = Logger.warn "rebroadcasting unknown message with id #{received_frame.message_id}}"
:ok = Logger.debug "rebroadcasting unknown message with id #{received_frame.message_id}}"
{:ok, socket, struct(receiving_connection, [buffer: rest]), struct(received_frame, [target: :broadcast])}
reason ->
:ok = Logger.warn(
:ok = Logger.debug(
"TCPOutConnection.handle_info: frame received failed: #{Atom.to_string(reason)}")
{:error, reason, socket, struct(receiving_connection, [buffer: rest])}
end
Expand All @@ -48,7 +48,7 @@ defmodule MAVLink.TCPOutConnection do
def connect(["tcpout", address, port], controlling_process) do
case :gen_tcp.connect(address, port, [:binary, active: :true]) do
{:ok, socket} ->
:ok = Logger.info("Opened tcpout:#{Enum.join(Tuple.to_list(address), ".")}:#{port}")
:ok = Logger.debug("Opened tcpout:#{Enum.join(Tuple.to_list(address), ".")}:#{port}")
send(
controlling_process,
{
Expand All @@ -62,7 +62,7 @@ defmodule MAVLink.TCPOutConnection do
)
:gen_tcp.controlling_process(socket, controlling_process)
other ->
:ok = Logger.warn("Could not open tcpout:#{Enum.join(Tuple.to_list(address), ".")}:#{port}: #{inspect(other)}. Retrying in 1 second")
:ok = Logger.debug("Could not open tcpout:#{Enum.join(Tuple.to_list(address), ".")}:#{port}: #{inspect(other)}. Retrying in 1 second")
:timer.sleep(1000)
connect(["tcpout", address, port], controlling_process)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/mavlink/udp_in_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule MAVLink.UDPInConnection do
case binary_to_frame_and_tail(raw) do
:not_a_frame ->
# Noise or malformed frame
:ok = Logger.warn("UDPInConnection.handle_info: Not a frame #{inspect(raw)}")
:ok = Logger.debug("UDPInConnection.handle_info: Not a frame #{inspect(raw)}")
{:error, :not_a_frame, {socket, source_addr, source_port}, receiving_connection}
{received_frame, _rest} -> # UDP sends frame per packet, so ignore rest
case validate_and_unpack(received_frame, dialect) do
Expand All @@ -39,10 +39,10 @@ defmodule MAVLink.UDPInConnection do
{:ok, {socket, source_addr, source_port}, receiving_connection, valid_frame}
:unknown_message ->
# We re-broadcast valid frames with unknown messages
:ok = Logger.warn "rebroadcasting unknown message with id #{received_frame.message_id}}"
:ok = Logger.debug "rebroadcasting unknown message with id #{received_frame.message_id}}"
{:ok, {socket, source_addr, source_port}, receiving_connection, struct(received_frame, [target: :broadcast])}
reason ->
:ok = Logger.warn(
:ok = Logger.debug(
"UDPInConnection.handle_info: frame received from " <>
"#{Enum.join(Tuple.to_list(source_addr), ".")}:#{source_port} failed: #{Atom.to_string(reason)}")
{:error, reason, {socket, source_addr, source_port}, receiving_connection}
Expand Down
8 changes: 4 additions & 4 deletions lib/mavlink/udp_out_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule MAVLink.UDPOutConnection do
case binary_to_frame_and_tail(raw) do
:not_a_frame ->
# Noise or malformed frame
:ok = Logger.warn("UDPOutConnection.handle_info: Not a frame #{inspect(raw)}")
:ok = Logger.debug("UDPOutConnection.handle_info: Not a frame #{inspect(raw)}")
{:error, :not_a_frame, {socket, source_addr, source_port}, receiving_connection}
{received_frame, _rest} -> # UDP sends frame per packet, so ignore rest
case validate_and_unpack(received_frame, dialect) do
Expand All @@ -39,10 +39,10 @@ defmodule MAVLink.UDPOutConnection do
{:ok, {socket, source_addr, source_port}, receiving_connection, valid_frame}
:unknown_message ->
# We re-broadcast valid frames with unknown messages
:ok = Logger.warn "relaying unknown message with id #{received_frame.message_id}}"
:ok = Logger.debug "relaying unknown message with id #{received_frame.message_id}}"
{:ok, {socket, source_addr, source_port}, receiving_connection, struct(received_frame, [target: :broadcast])}
reason ->
:ok = Logger.warn(
:ok = Logger.debug(
"UDPOutConnection.handle_info: frame received from " <>
"#{Enum.join(Tuple.to_list(source_addr), ".")}:#{source_port} failed: #{Atom.to_string(reason)}")
{:error, reason, {socket, source_addr, source_port}, receiving_connection}
Expand All @@ -68,7 +68,7 @@ defmodule MAVLink.UDPOutConnection do
)
:gen_udp.controlling_process(socket, controlling_process)
other ->
:ok = Logger.warn("Could not open udpout:#{Enum.join(Tuple.to_list(address), ".")}:#{port}: #{inspect(other)}. Retrying in 1 second")
:ok = Logger.debug("Could not open udpout:#{Enum.join(Tuple.to_list(address), ".")}:#{port}: #{inspect(other)}. Retrying in 1 second")
:timer.sleep(1000)
connect(["udpout", address, port], controlling_process)
end
Expand Down

0 comments on commit 748aaa6

Please sign in to comment.