@@ -93,7 +93,6 @@ mod wallet;
93
93
pub use bip39;
94
94
pub use bitcoin;
95
95
pub use lightning;
96
- use lightning:: ln:: msgs:: RoutingMessageHandler ;
97
96
pub use lightning_invoice;
98
97
99
98
pub use error:: Error as NodeError ;
@@ -126,11 +125,13 @@ use lightning::chain::{chainmonitor, BestBlock, Confirm, Watch};
126
125
use lightning:: ln:: channelmanager:: {
127
126
self , ChainParameters , ChannelManagerReadArgs , PaymentId , RecipientOnionFields , Retry ,
128
127
} ;
128
+ use lightning:: ln:: msgs:: RoutingMessageHandler ;
129
129
use lightning:: ln:: peer_handler:: { IgnoringMessageHandler , MessageHandler } ;
130
130
use lightning:: ln:: { PaymentHash , PaymentPreimage } ;
131
131
use lightning:: routing:: scoring:: { ProbabilisticScorer , ProbabilisticScoringParameters } ;
132
132
133
133
use lightning:: util:: config:: { ChannelHandshakeConfig , ChannelHandshakeLimits , UserConfig } ;
134
+ pub use lightning:: util:: logger:: Level as LogLevel ;
134
135
use lightning:: util:: ser:: ReadableArgs ;
135
136
136
137
use lightning_background_processor:: process_events_async;
@@ -173,6 +174,7 @@ const DEFAULT_NETWORK: Network = Network::Bitcoin;
173
174
const DEFAULT_LISTENING_ADDR : & str = "0.0.0.0:9735" ;
174
175
const DEFAULT_CLTV_EXPIRY_DELTA : u32 = 144 ;
175
176
const DEFAULT_ESPLORA_SERVER_URL : & str = "https://blockstream.info/api" ;
177
+ const DEFAULT_LOG_LEVEL : LogLevel = LogLevel :: Debug ;
176
178
177
179
// The 'stop gap' parameter used by BDK's wallet sync. This seems to configure the threshold
178
180
// number of blocks after which BDK stops looking for scripts belonging to the wallet.
@@ -207,6 +209,7 @@ const WALLET_KEYS_SEED_LEN: usize = 64;
207
209
/// | `network` | Network::Bitcoin |
208
210
/// | `listening_address` | 0.0.0.0:9735 |
209
211
/// | `default_cltv_expiry_delta` | 144 |
212
+ /// | `log_level` | `Debug` |
210
213
///
211
214
pub struct Config {
212
215
/// The path where the underlying LDK and BDK persist their data.
@@ -217,6 +220,10 @@ pub struct Config {
217
220
pub listening_address : Option < NetAddress > ,
218
221
/// The default CLTV expiry delta to be used for payments.
219
222
pub default_cltv_expiry_delta : u32 ,
223
+ /// The level at which we log messages.
224
+ ///
225
+ /// Any messages below this level will be excluded from the logs.
226
+ pub log_level : LogLevel ,
220
227
}
221
228
222
229
impl Default for Config {
@@ -226,6 +233,7 @@ impl Default for Config {
226
233
network : DEFAULT_NETWORK ,
227
234
listening_address : Some ( DEFAULT_LISTENING_ADDR . parse ( ) . unwrap ( ) ) ,
228
235
default_cltv_expiry_delta : DEFAULT_CLTV_EXPIRY_DELTA ,
236
+ log_level : DEFAULT_LOG_LEVEL ,
229
237
}
230
238
}
231
239
}
@@ -348,6 +356,12 @@ impl Builder {
348
356
config. listening_address = Some ( listening_address) ;
349
357
}
350
358
359
+ /// Sets the level at which [`Node`] will log messages.
360
+ pub fn set_log_level ( & self , level : LogLevel ) {
361
+ let mut config = self . config . write ( ) . unwrap ( ) ;
362
+ config. log_level = level;
363
+ }
364
+
351
365
/// Builds a [`Node`] instance with a [`FilesystemStore`] backend and according to the options
352
366
/// previously configured.
353
367
pub fn build ( & self ) -> Arc < Node < FilesystemStore > > {
@@ -371,7 +385,7 @@ impl Builder {
371
385
372
386
// Initialize the Logger
373
387
let log_file_path = format ! ( "{}/ldk_node.log" , config. storage_dir_path) ;
374
- let logger = Arc :: new ( FilesystemLogger :: new ( log_file_path) ) ;
388
+ let logger = Arc :: new ( FilesystemLogger :: new ( log_file_path, config . log_level ) ) ;
375
389
376
390
// Initialize the on-chain wallet and chain access
377
391
let seed_bytes = match & * self . entropy_source_config . read ( ) . unwrap ( ) {
0 commit comments