@@ -8,6 +8,7 @@ use clap::Parser;
88use ethers_signers:: { coins_bip39:: English , MnemonicBuilder } ;
99use tokio:: signal:: unix:: { signal, SignalKind } ;
1010
11+ use log:: { debug, info, warn} ;
1112use tap_aggregator:: server;
1213
1314#[ derive( Parser , Debug ) ]
@@ -39,7 +40,15 @@ struct Args {
3940
4041#[ tokio:: main]
4142async fn main ( ) -> Result < ( ) > {
43+ // Initialize the logger.
44+ // Set the log level by setting the RUST_LOG environment variable.
45+ // We prefer using tracing_subscriber as the logging backend because jsonrpsee
46+ // uses it, and it shows jsonrpsee log spans in the logs (to see client IP, etc).
47+ // See https://github.com/paritytech/jsonrpsee/pull/922 for more info.
48+ tracing_subscriber:: fmt:: init ( ) ;
49+
4250 let args = Args :: parse ( ) ;
51+ debug ! ( "Settings: {:?}" , args) ;
4352
4453 // Create a wallet from the mnemonic.
4554 let wallet = MnemonicBuilder :: < English > :: default ( )
@@ -55,21 +64,23 @@ async fn main() -> Result<()> {
5564 args. max_connections ,
5665 )
5766 . await ?;
67+ info ! ( "Server started. Listening on port {}." , args. port) ;
5868
5969 // Have tokio wait for SIGTERM or SIGINT.
6070 let mut signal_sigint = signal ( SignalKind :: interrupt ( ) ) ?;
6171 let mut signal_sigterm = signal ( SignalKind :: terminate ( ) ) ?;
6272 tokio:: select! {
63- _ = signal_sigint. recv( ) => println !( "SIGINT" ) ,
64- _ = signal_sigterm. recv( ) => println !( "SIGTERM" ) ,
73+ _ = signal_sigint. recv( ) => debug !( "Received SIGINT. " ) ,
74+ _ = signal_sigterm. recv( ) => debug !( "Received SIGTERM. " ) ,
6575 }
6676
6777 // If we're here, we've received a signal to exit.
68- println ! ( "Shutting down..." ) ;
78+ info ! ( "Shutting down..." ) ;
6979
7080 // Stop the server and wait for it to finish gracefully.
7181 handle. stop ( ) ?;
7282 handle. stopped ( ) . await ;
7383
84+ debug ! ( "Goodbye!" ) ;
7485 Ok ( ( ) )
7586}
0 commit comments