@@ -22,6 +22,8 @@ defmodule M51.MatrixClient.Sender do
2222 """
2323 use Task , restart: :permanent
2424
25+ require Logger
26+
2527 # totals 4 minutes, as the backoff of each attempt is 2^(number of attempts so far)
2628 @ max_attempts 7
2729
@@ -62,15 +64,15 @@ defmodule M51.MatrixClient.Sender do
6264
6365 body = Jason . encode! ( event )
6466
65- IO . inspect ( body , label: "sending ")
67+ Logger . debug ( "Sending event: #{ body } ")
6668
6769 case M51.Matrix.RawClient . put ( raw_client , path , body ) do
6870 { :ok , _body } ->
6971 nil
7072
7173 { :error , _status_code , reason } ->
7274 if nb_attempts < @ max_attempts do
73- IO . inspect ( reason , label: "error while sending event, retrying")
75+ Logger . warn ( "Error while sending event, retrying: #{ reason } ")
7476 backoff_delay = :math . pow ( 2 , nb_attempts )
7577 Process . sleep ( round ( backoff_delay * 1000 ) )
7678
@@ -83,7 +85,7 @@ defmodule M51.MatrixClient.Sender do
8385 nb_attempts + 1
8486 )
8587 else
86- IO . inspect ( reason , label: "error while sending event, giving up")
88+ Logger . warn ( "Error while sending event, giving up: #{ reason } ")
8789 state = M51.IrcConn.Supervisor . matrix_state ( sup_pid )
8890 channel = M51.MatrixClient.State . room_irc_channel ( state , room_id )
8991
0 commit comments