@@ -111,20 +111,22 @@ impl Default for LiquiditySourceConfig {
111111
112112#[ derive( Clone ) ]
113113enum 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 > } ,
116116 Custom ( Arc < dyn LogWriter > ) ,
117117}
118118
119119impl std:: fmt:: Debug for LogWriterConfig {
120120 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
121121 match self {
122- LogWriterConfig :: File { log_level , log_file_path } => f
122+ LogWriterConfig :: File { max_log_level , log_file_path } => f
123123 . debug_struct ( "LogWriterConfig" )
124- . field ( "log_level " , log_level )
124+ . field ( "max_log_level " , max_log_level )
125125 . field ( "log_file_path" , log_file_path)
126126 . 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+ } ,
128130 LogWriterConfig :: Custom ( _) => {
129131 f. debug_tuple ( "Custom" ) . field ( & "<config internal to custom log writer>" ) . finish ( )
130132 } ,
@@ -331,19 +333,24 @@ impl NodeBuilder {
331333 ///
332334 /// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
333335 /// [`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`].
335339 ///
336340 /// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
337341 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 > ,
339343 ) -> & 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 } ) ;
341345 self
342346 }
343347
344348 /// 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 } ) ;
347354 self
348355 }
349356
@@ -658,7 +665,9 @@ impl ArcedNodeBuilder {
658665 ///
659666 /// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
660667 /// [`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`].
662671 ///
663672 /// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
664673 pub fn set_filesystem_logger (
@@ -668,7 +677,10 @@ impl ArcedNodeBuilder {
668677 }
669678
670679 /// 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 > ) {
672684 self . inner . write ( ) . unwrap ( ) . set_log_facade_logger ( log_level) ;
673685 }
674686
@@ -1305,16 +1317,19 @@ fn setup_logger(
13051317 log_writer_config : & Option < LogWriterConfig > , config : & Config ,
13061318) -> Result < Arc < Logger > , BuildError > {
13071319 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 } ) => {
13091321 let log_file_path = log_file_path
13101322 . clone ( )
13111323 . 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 ) ;
13131325
1314- Logger :: new_fs_writer ( log_file_path, log_level )
1326+ Logger :: new_fs_writer ( log_file_path, max_log_level )
13151327 . map_err ( |_| BuildError :: LoggerSetupFailed ) ?
13161328 } ,
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+ } ,
13181333
13191334 Some ( LogWriterConfig :: Custom ( custom_log_writer) ) => {
13201335 Logger :: new_custom_writer ( Arc :: clone ( & custom_log_writer) )
0 commit comments