Skip to content

Commit c647d1f

Browse files
committed
refactor: remove default_log_* functions
Removes the default_log_* functions that were hitherto public functions used to share private constants. These constants (DEFAULT_LOG_LEVEL and the renamed DEFAULT_LOG_FILE_PATH) have been made public instead.
1 parent 902a294 commit c647d1f

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

src/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
99
use crate::config::{
10-
default_log_file_path, default_log_level, default_user_config, Config, EsploraSyncConfig,
11-
FilesystemLoggerConfig, WALLET_KEYS_SEED_LEN,
10+
default_user_config, Config, EsploraSyncConfig, FilesystemLoggerConfig, DEFAULT_LOG_FILE_PATH,
11+
DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
1212
};
1313

1414
use crate::connection::ConnectionManager;
@@ -1295,9 +1295,9 @@ fn setup_logger(config: &LogWriterConfig) -> Result<Arc<Logger>, BuildError> {
12951295
let log_file_path = if let Some(fp) = &fs_logger_config.log_file_path {
12961296
fp
12971297
} else {
1298-
&default_log_file_path()
1298+
DEFAULT_LOG_FILE_PATH
12991299
};
1300-
let log_level = fs_logger_config.log_level.unwrap_or(default_log_level());
1300+
let log_level = fs_logger_config.log_level.unwrap_or(DEFAULT_LOG_LEVEL);
13011301

13021302
Ok(Arc::new(
13031303
Logger::new_fs_writer(log_file_path, log_level)

src/config.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ const DEFAULT_LDK_WALLET_SYNC_INTERVAL_SECS: u64 = 30;
2929
const DEFAULT_FEE_RATE_CACHE_UPDATE_INTERVAL_SECS: u64 = 60 * 10;
3030
const DEFAULT_PROBING_LIQUIDITY_LIMIT_MULTIPLIER: u64 = 3;
3131
const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS: u64 = 25_000;
32-
const DEFAULT_LOG_FILE_PATH: &'static str = "ldk_node.log";
33-
const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Debug;
32+
33+
/// The default log level.
34+
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Debug;
35+
36+
/// The default log file path.
37+
pub const DEFAULT_LOG_FILE_PATH: &'static str = "/tmp/ldk_node/ldk_node.log";
3438

3539
// The 'stop gap' parameter used by BDK's wallet sync. This seems to configure the threshold
3640
// number of derivation indexes after which BDK stops looking for new scripts belonging to the wallet.
@@ -436,8 +440,7 @@ pub struct FilesystemLoggerConfig {
436440
///
437441
/// This specifies the log file path if a destination other than the storage
438442
/// directory, i.e. [`Config::storage_dir_path`], is preferred. If unconfigured,
439-
/// defaults to [`DEFAULT_STORAGE_DIR_PATH`]/[`DEFAULT_LOG_FILE_PATH`], i.e.
440-
/// `/tmp/ldk_node/ldk_node.log`
443+
/// defaults to [`DEFAULT_LOG_FILE_PATH`]
441444
pub log_file_path: Option<String>,
442445
/// This specifies the log level.
443446
///
@@ -447,19 +450,13 @@ pub struct FilesystemLoggerConfig {
447450

448451
impl Default for FilesystemLoggerConfig {
449452
fn default() -> Self {
450-
let log_file_path = default_log_file_path();
451-
Self { log_file_path: Some(log_file_path), log_level: Some(default_log_level()) }
453+
Self {
454+
log_file_path: Some(DEFAULT_LOG_FILE_PATH.to_string()),
455+
log_level: Some(DEFAULT_LOG_LEVEL),
456+
}
452457
}
453458
}
454459

455-
pub(crate) fn default_log_file_path() -> String {
456-
format!("{}/{}", DEFAULT_STORAGE_DIR_PATH, DEFAULT_LOG_FILE_PATH)
457-
}
458-
459-
pub(crate) fn default_log_level() -> LogLevel {
460-
DEFAULT_LOG_LEVEL
461-
}
462-
463460
#[cfg(test)]
464461
mod tests {
465462
use std::str::FromStr;

0 commit comments

Comments
 (0)