Browse Source
551: Configurable log levels on both taker and maker r=da-kami a=da-kami
Add configurable log levels on taker and maker and start tracing connection related information to track down a problem where the taker does not receive orders but there are not connection errors on both sides.
https://github.com/itchysats/itchysats/issues/550
Co-authored-by: Daniel Karzel <daniel@comit.network>
new-http-api
bors[bot]
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with
22 additions and
5 deletions
daemon/src/fan_out.rs
daemon/src/maker.rs
daemon/src/maker_inc_connections.rs
daemon/src/oracle.rs
daemon/src/send_to_socket.rs
daemon/src/taker.rs
daemon/src/taker_cfd.rs
@ -23,7 +23,11 @@ where
async fn handle ( & mut self , message : M , _ : & mut xtra ::Context < Self > ) {
for receiver in & self . receivers {
// Not sure why here is no `do_send_async` ...
let _ = receiver . do_send ( message . clone ( ) ) ;
if receiver . do_send ( message . clone ( ) ) . is_err ( ) {
tracing ::error ! (
"Fan out actor was unable to send to other actor - we should never see this."
)
}
}
}
}
@ -48,6 +48,10 @@ struct Opts {
#[ clap(short, long) ]
json : bool ,
/// Configure the log level, e.g.: one of Error, Warn, Info, Debug, Trace
#[ clap(short, long, default_value = " Debug " ) ]
log_level : LevelFilter ,
/// The time interval until potential settlement of each CFD in hours
#[ clap(long, default_value = " 24 " ) ]
settlement_time_interval_hours : u8 ,
@ -142,7 +146,7 @@ impl Network {
async fn main ( ) -> Result < ( ) > {
let opts = Opts ::parse ( ) ;
logger ::init ( LevelFilter ::DEBUG , opts . json ) . context ( "initialize logger" ) ? ;
logger ::init ( opts . log_level , opts . json ) . context ( "initialize logger" ) ? ;
tracing ::info ! ( "Running version: {}" , env ! ( "VERGEN_GIT_SEMVER_LIGHTWEIGHT" ) ) ;
let data_dir = opts
@ -151,7 +151,8 @@ impl Actor {
async fn handle_broadcast_order ( & mut self , msg : BroadcastOrder ) -> Result < ( ) > {
let order = msg . 0 ;
for conn in self . write_connections . values ( ) {
for ( taker_id , conn ) in self . write_connections . clone ( ) {
tracing ::trace ! ( % taker_id , "sending new order for broadcast to connection: {:?}" , order ) ;
conn . do_send_async ( wire ::MakerToTaker ::CurrentOrder ( order . clone ( ) ) )
. await ? ;
}
@ -112,7 +112,6 @@ impl Actor {
) ) ;
if self . announcements . get ( & event_id ) . is_some ( ) {
tracing ::trace ! ( "Announcement already known: {}" , event_id , ) ;
continue ;
}
let this = ctx . address ( ) . expect ( "self to be alive" ) ;
@ -33,6 +33,8 @@ where
async fn handle ( & mut self , message : T , ctx : & mut xtra ::Context < Self > ) {
let message_name = message . to_string ( ) ; // send consumes the message, avoid a clone just in case it errors by getting the name here
tracing ::trace ! ( % message_name , "send to socket message" ) ;
if let Err ( e ) = self . write . send ( message ) . await {
tracing ::error ! ( "Failed to write message {} to socket: {}" , message_name , e ) ;
ctx . stop ( ) ;
@ -47,6 +47,10 @@ struct Opts {
#[ clap(short, long) ]
json : bool ,
/// Configure the log level, e.g.: one of Error, Warn, Info, Debug, Trace
#[ clap(short, long, default_value = " Debug " ) ]
log_level : LevelFilter ,
#[ clap(subcommand) ]
network : Network ,
}
@ -141,7 +145,7 @@ impl Network {
async fn main ( ) -> Result < ( ) > {
let opts = Opts ::parse ( ) ;
logger ::init ( LevelFilter ::DEBUG , opts . json ) . context ( "initialize logger" ) ? ;
logger ::init ( opts . log_level , opts . json ) . context ( "initialize logger" ) ? ;
tracing ::info ! ( "Running version: {}" , env ! ( "VERGEN_GIT_SEMVER_LIGHTWEIGHT" ) ) ;
let data_dir = opts
@ -300,6 +300,7 @@ where
impl < O , M , W > Actor < O , M , W > {
async fn handle_new_order ( & mut self , order : Option < Order > ) -> Result < ( ) > {
tracing ::trace ! ( "new order {:?}" , order ) ;
match order {
Some ( mut order ) = > {
order . origin = Origin ::Theirs ;
@ -737,6 +738,8 @@ where
}
} ;
tracing ::trace ! ( "message from maker: {:?}" , msg ) ;
match msg {
wire ::MakerToTaker ::CurrentOrder ( current_order ) = > {
log_error ! ( self . handle_new_order ( current_order ) )