@@ -111,20 +111,22 @@ impl Default for LiquiditySourceConfig {
111
111
112
112
#[ derive( Clone ) ]
113
113
enum LogWriterConfig {
114
- File { log_file_path : Option < String > , log_level : Option < LogLevel > } ,
115
- Log ( LogLevel ) ,
114
+ File { log_file_path : Option < String > , max_log_level : Option < LogLevel > } ,
115
+ Log { max_log_level : Option < LogLevel > } ,
116
116
Custom ( Arc < dyn LogWriter > ) ,
117
117
}
118
118
119
119
impl std:: fmt:: Debug for LogWriterConfig {
120
120
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
121
121
match self {
122
- LogWriterConfig :: File { log_level , log_file_path } => f
122
+ LogWriterConfig :: File { max_log_level , log_file_path } => f
123
123
. debug_struct ( "LogWriterConfig" )
124
- . field ( "log_level " , log_level )
124
+ . field ( "max_log_level " , max_log_level )
125
125
. field ( "log_file_path" , log_file_path)
126
126
. finish ( ) ,
127
- LogWriterConfig :: Log ( level) => f. debug_tuple ( "Log" ) . field ( level) . finish ( ) ,
127
+ LogWriterConfig :: Log { max_log_level } => {
128
+ f. debug_tuple ( "Log" ) . field ( max_log_level) . finish ( )
129
+ } ,
128
130
LogWriterConfig :: Custom ( _) => {
129
131
f. debug_tuple ( "Custom" ) . field ( & "<config internal to custom log writer>" ) . finish ( )
130
132
} ,
@@ -331,19 +333,24 @@ impl NodeBuilder {
331
333
///
332
334
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
333
335
/// [`Config::storage_dir_path`] if set to `None`.
334
- /// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
336
+ ///
337
+ /// If set, the `max_log_level` sets the maximum log level. Otherwise, the latter defaults to
338
+ /// [`DEFAULT_LOG_LEVEL`].
335
339
///
336
340
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
337
341
pub fn set_filesystem_logger (
338
- & mut self , log_file_path : Option < String > , log_level : Option < LogLevel > ,
342
+ & mut self , log_file_path : Option < String > , max_log_level : Option < LogLevel > ,
339
343
) -> & mut Self {
340
- self . log_writer_config = Some ( LogWriterConfig :: File { log_file_path, log_level } ) ;
344
+ self . log_writer_config = Some ( LogWriterConfig :: File { log_file_path, max_log_level } ) ;
341
345
self
342
346
}
343
347
344
348
/// Configures the [`Node`] instance to write logs to the [`log`](https://crates.io/crates/log) facade.
345
- pub fn set_log_facade_logger ( & mut self , log_level : LogLevel ) -> & mut Self {
346
- self . log_writer_config = Some ( LogWriterConfig :: Log ( log_level) ) ;
349
+ ///
350
+ /// If set, the `max_log_level` sets the maximum log level. Otherwise, the latter defaults to
351
+ /// [`DEFAULT_LOG_LEVEL`].
352
+ pub fn set_log_facade_logger ( & mut self , max_log_level : Option < LogLevel > ) -> & mut Self {
353
+ self . log_writer_config = Some ( LogWriterConfig :: Log { max_log_level } ) ;
347
354
self
348
355
}
349
356
@@ -658,7 +665,9 @@ impl ArcedNodeBuilder {
658
665
///
659
666
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
660
667
/// [`Config::storage_dir_path`] if set to `None`.
661
- /// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
668
+ ///
669
+ /// If set, the `max_log_level` sets the maximum log level. Otherwise, the latter defaults to
670
+ /// [`DEFAULT_LOG_LEVEL`].
662
671
///
663
672
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
664
673
pub fn set_filesystem_logger (
@@ -668,7 +677,10 @@ impl ArcedNodeBuilder {
668
677
}
669
678
670
679
/// Configures the [`Node`] instance to write logs to the [`log`](https://crates.io/crates/log) facade.
671
- pub fn set_log_facade_logger ( & self , log_level : LogLevel ) {
680
+ ///
681
+ /// If set, the `max_log_level` sets the maximum log level. Otherwise, the latter defaults to
682
+ /// [`DEFAULT_LOG_LEVEL`].
683
+ pub fn set_log_facade_logger ( & self , log_level : Option < LogLevel > ) {
672
684
self . inner . write ( ) . unwrap ( ) . set_log_facade_logger ( log_level) ;
673
685
}
674
686
@@ -1305,16 +1317,19 @@ fn setup_logger(
1305
1317
log_writer_config : & Option < LogWriterConfig > , config : & Config ,
1306
1318
) -> Result < Arc < Logger > , BuildError > {
1307
1319
let logger = match log_writer_config {
1308
- Some ( LogWriterConfig :: File { log_file_path, log_level } ) => {
1320
+ Some ( LogWriterConfig :: File { log_file_path, max_log_level } ) => {
1309
1321
let log_file_path = log_file_path
1310
1322
. clone ( )
1311
1323
. unwrap_or_else ( || format ! ( "{}/{}" , config. storage_dir_path, DEFAULT_LOG_FILENAME ) ) ;
1312
- let log_level = log_level . unwrap_or_else ( || DEFAULT_LOG_LEVEL ) ;
1324
+ let max_log_level = max_log_level . unwrap_or_else ( || DEFAULT_LOG_LEVEL ) ;
1313
1325
1314
- Logger :: new_fs_writer ( log_file_path, log_level )
1326
+ Logger :: new_fs_writer ( log_file_path, max_log_level )
1315
1327
. map_err ( |_| BuildError :: LoggerSetupFailed ) ?
1316
1328
} ,
1317
- Some ( LogWriterConfig :: Log ( log_level) ) => Logger :: new_log_facade ( * log_level) ,
1329
+ Some ( LogWriterConfig :: Log { max_log_level } ) => {
1330
+ let max_log_level = max_log_level. unwrap_or_else ( || DEFAULT_LOG_LEVEL ) ;
1331
+ Logger :: new_log_facade ( max_log_level)
1332
+ } ,
1318
1333
1319
1334
Some ( LogWriterConfig :: Custom ( custom_log_writer) ) => {
1320
1335
Logger :: new_custom_writer ( Arc :: clone ( & custom_log_writer) )
0 commit comments