@@ -93,7 +93,6 @@ mod wallet;
9393pub use bip39;
9494pub use bitcoin;
9595pub use lightning;
96- use lightning:: ln:: msgs:: RoutingMessageHandler ;
9796pub use lightning_invoice;
9897
9998pub use error:: Error as NodeError ;
@@ -126,11 +125,13 @@ use lightning::chain::{chainmonitor, BestBlock, Confirm, Watch};
126125use lightning:: ln:: channelmanager:: {
127126 self , ChainParameters , ChannelManagerReadArgs , PaymentId , RecipientOnionFields , Retry ,
128127} ;
128+ use lightning:: ln:: msgs:: RoutingMessageHandler ;
129129use lightning:: ln:: peer_handler:: { IgnoringMessageHandler , MessageHandler } ;
130130use lightning:: ln:: { PaymentHash , PaymentPreimage } ;
131131use lightning:: routing:: scoring:: { ProbabilisticScorer , ProbabilisticScoringParameters } ;
132132
133133use lightning:: util:: config:: { ChannelHandshakeConfig , ChannelHandshakeLimits , UserConfig } ;
134+ pub use lightning:: util:: logger:: Level as LogLevel ;
134135use lightning:: util:: ser:: ReadableArgs ;
135136
136137use lightning_background_processor:: process_events_async;
@@ -173,6 +174,7 @@ const DEFAULT_NETWORK: Network = Network::Bitcoin;
173174const DEFAULT_LISTENING_ADDR : & str = "0.0.0.0:9735" ;
174175const DEFAULT_CLTV_EXPIRY_DELTA : u32 = 144 ;
175176const DEFAULT_ESPLORA_SERVER_URL : & str = "https://blockstream.info/api" ;
177+ const DEFAULT_LOG_LEVEL : LogLevel = LogLevel :: Debug ;
176178
177179// The 'stop gap' parameter used by BDK's wallet sync. This seems to configure the threshold
178180// number of blocks after which BDK stops looking for scripts belonging to the wallet.
@@ -217,6 +219,10 @@ pub struct Config {
217219 pub listening_address : Option < NetAddress > ,
218220 /// The default CLTV expiry delta to be used for payments.
219221 pub default_cltv_expiry_delta : u32 ,
222+ /// The level at which we log messages.
223+ ///
224+ /// Any messages below this level will be excluded from the logs.
225+ pub log_level : LogLevel ,
220226}
221227
222228impl Default for Config {
@@ -226,6 +232,7 @@ impl Default for Config {
226232 network : DEFAULT_NETWORK ,
227233 listening_address : Some ( DEFAULT_LISTENING_ADDR . parse ( ) . unwrap ( ) ) ,
228234 default_cltv_expiry_delta : DEFAULT_CLTV_EXPIRY_DELTA ,
235+ log_level : DEFAULT_LOG_LEVEL ,
229236 }
230237 }
231238}
@@ -348,6 +355,12 @@ impl Builder {
348355 config. listening_address = Some ( listening_address) ;
349356 }
350357
358+ /// Sets the level at which [`Node`] will log messages.
359+ pub fn set_log_level ( & self , level : LogLevel ) {
360+ let mut config = self . config . write ( ) . unwrap ( ) ;
361+ config. log_level = level;
362+ }
363+
351364 /// Builds a [`Node`] instance with a [`FilesystemStore`] backend and according to the options
352365 /// previously configured.
353366 pub fn build ( & self ) -> Arc < Node < FilesystemStore > > {
@@ -371,7 +384,7 @@ impl Builder {
371384
372385 // Initialize the Logger
373386 let log_file_path = format ! ( "{}/ldk_node.log" , config. storage_dir_path) ;
374- let logger = Arc :: new ( FilesystemLogger :: new ( log_file_path) ) ;
387+ let logger = Arc :: new ( FilesystemLogger :: new ( log_file_path, config . log_level ) ) ;
375388
376389 // Initialize the on-chain wallet and chain access
377390 let seed_bytes = match & * self . entropy_source_config . read ( ) . unwrap ( ) {
0 commit comments