@@ -298,51 +298,60 @@ impl DriaP2PClient {
298
298
299
299
SwarmEvent :: ConnectionEstablished {
300
300
peer_id,
301
- num_established,
302
301
connection_id,
303
302
endpoint,
304
303
..
305
304
} => {
306
- log:: info!(
307
- "Connection ({connection_id}) established with peer {peer_id} ({} connections) at {:?}" ,
308
- num_established,
309
- endpoint
310
- ) ;
305
+ if endpoint. is_dialer ( ) {
306
+ // we only care about logs about the ones that we have dialed
307
+ log:: info!(
308
+ "Connection ({connection_id}) established with {peer_id} at {}" ,
309
+ endpoint. get_remote_address( )
310
+ ) ;
311
+ } else {
312
+ log:: debug!(
313
+ "Connection ({connection_id}) established with {peer_id} from {}" ,
314
+ endpoint. get_remote_address( )
315
+ ) ;
316
+ }
311
317
}
312
318
313
319
SwarmEvent :: ConnectionClosed {
314
320
peer_id,
315
321
connection_id,
316
322
endpoint,
317
- num_established,
318
323
cause,
324
+ ..
319
325
} => {
320
- log:: warn!(
321
- "Connection ({connection_id}) closed for {peer_id} ({} connections)\n Cause: {}" ,
322
- num_established,
323
- cause
324
- . map( |c| c. to_string( ) )
325
- . unwrap_or( "Unknown" . to_string( ) )
326
- ) ;
327
-
326
+ let cause = cause
327
+ . map ( |c| c. to_string ( ) )
328
+ . unwrap_or ( "Unknown" . to_string ( ) ) ;
328
329
if endpoint. is_dialer ( ) {
330
+ // we only care about logs about the ones that we have dialed
331
+ log:: warn!( "Connection ({connection_id}) closed for {peer_id}\n Cause: {cause}" ) ;
332
+
329
333
let addr = endpoint. get_remote_address ( ) ;
330
334
log:: info!( "Dialing {} again at {}" , peer_id, addr) ;
331
- if let Err ( e ) = self . swarm . dial (
335
+ if let Err ( err ) = self . swarm . dial (
332
336
DialOpts :: peer_id ( peer_id)
333
337
. addresses ( vec ! [ addr. clone( ) ] )
334
338
. condition ( PeerCondition :: DisconnectedAndNotDialing )
335
339
. build ( ) ,
336
340
) {
337
- log:: error!( "Could not dial peer {}: {:?}" , peer_id , e ) ;
341
+ log:: error!( "Could not dial peer {peer_id }: {err :?}" ) ;
338
342
}
343
+ } else {
344
+ log:: debug!(
345
+ "Connection ({connection_id}) closed for {peer_id}\n Cause: {cause}"
346
+ ) ;
339
347
}
340
348
}
341
349
342
350
SwarmEvent :: ExpiredListenAddr {
343
351
address,
344
352
listener_id,
345
353
} => {
354
+ // this may happen when your connection is lost, e.g. you turn off your machine / internet
346
355
log:: warn!( "Listener ({listener_id}) expired: {address}" ) ;
347
356
}
348
357
0 commit comments