Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 28 additions & 47 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILE_PATH, DEFAULT_LOG_LEVEL,
DEFAULT_STORAGE_DIR_PATH, WALLET_KEYS_SEED_LEN,
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL,
WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -111,18 +111,7 @@ impl Default for LiquiditySourceConfig {

#[derive(Clone)]
enum LogWriterConfig {
File {
/// The log file path.
///
/// This specifies the log file path if a destination other than the storage
/// directory, i.e. [`Config::storage_dir_path`], is preferred. If unconfigured,
/// defaults to [`DEFAULT_LOG_FILE_PATH`] in default storage directory.
log_file_path: Option<String>,
/// This specifies the log level.
///
/// If unconfigured, defaults to `Debug`.
log_level: Option<LogLevel>,
},
File { log_file_path: Option<String>, log_level: Option<LogLevel> },
Log(LogLevel),
Custom(Arc<dyn LogWriter>),
}
Expand All@@ -143,15 +132,6 @@ impl std::fmt::Debug for LogWriterConfig {
}
}

impl Default for LogWriterConfig {
fn default() -> Self {
Self::File {
log_file_path: Some(DEFAULT_LOG_FILE_PATH.to_string()),
log_level: Some(DEFAULT_LOG_LEVEL),
}
}
}

/// An error encountered during building a [`Node`].
///
/// [`Node`]: crate::Node
Expand DownExpand Up@@ -349,9 +329,11 @@ impl NodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILE_PATH`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&mut self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) -> &mut Self {
Expand DownExpand Up@@ -674,9 +656,11 @@ impl ArcedNodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILENAME`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) {
Expand DownExpand Up@@ -1317,34 +1301,31 @@ fn build_with_store_internal(
}

/// Sets up the node logger.
///
/// If `log_writer_conf` is set to None, uses [`LogWriterConfig::default()`].
/// The `node_conf` is provided to access the configured storage directory.
fn setup_logger(
log_writer_conf: &Option<LogWriterConfig>, node_conf: &Config,
log_writer_config: &Option<LogWriterConfig>, config: &Config,
) -> Result<Arc<Logger>, BuildError> {
let is_default = log_writer_conf.is_none();
let default_lw_config = LogWriterConfig::default();
let log_writer_config =
if let Some(conf) = log_writer_conf { conf } else { &default_lw_config };

let logger = match log_writer_config {
LogWriterConfig::File { log_file_path, log_level } => {
let fp = DEFAULT_LOG_FILE_PATH
.replace(DEFAULT_STORAGE_DIR_PATH, &node_conf.storage_dir_path);
let log_file_path =
if is_default { &fp } else { log_file_path.as_ref().map(|p| p).unwrap_or(&fp) };

let log_level = log_level.unwrap_or(DEFAULT_LOG_LEVEL);
Some(LogWriterConfig::File { log_file_path, log_level }) => {
let log_file_path = log_file_path
.clone()
.unwrap_or_else(|| format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME));
let log_level = log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL);

@arik-soarik-soJan 30, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how much we gain from using an or_else closure for a constant instead of or here.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, true


Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
LogWriterConfig::Log(log_level) => Logger::new_log_facade(*log_level),
Some(LogWriterConfig::Log(log_level)) => Logger::new_log_facade(*log_level),

LogWriterConfig::Custom(custom_log_writer) => {
Some(LogWriterConfig::Custom(custom_log_writer)) => {
Logger::new_custom_writer(Arc::clone(&custom_log_writer))
},
None => {
// Default to use `FileWriter`
let log_file_path = format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME);
let log_level = DEFAULT_LOG_LEVEL;
Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
};

Ok(Arc::new(logger))
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,8 +32,8 @@ const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS: u64 = 25_000;
/// The default log level.
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Debug;

/// The default log file path.
pub const DEFAULT_LOG_FILE_PATH: &'static str = "/tmp/ldk_node/ldk_node.log";
/// The default log file name.
pub const DEFAULT_LOG_FILENAME: &'static str = "ldk_node.log";

/// The default storage directory.
pub const DEFAULT_STORAGE_DIR_PATH: &str = "/tmp/ldk_node";
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -144,7 +144,6 @@ use types::{
pub use types::{ChannelDetails, CustomTlvRecord, PeerDetails, UserChannelId};

use logger::{log_error, log_info, log_trace, LdkLogger, Logger};
pub use logger::{LogLevel, LogRecord, LogWriter};

use lightning::chain::BestBlock;
use lightning::events::bump_transaction::Wallet as LdkWallet;
Expand Down
12 changes: 6 additions & 6 deletions src/logger.rs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how cargo fmt didn't catch that?

@tnulltnullJan 30, 2025

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t touch macros.

Original file line numberDiff line numberDiff line change
Expand Up@@ -143,10 +143,10 @@ impl LogWriter for Writer {
($log_level:expr, $($args:tt)*) => {
match $log_level {
LogLevel::Gossip | LogLevel::Trace => trace!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
}
};
}
Expand DownExpand Up@@ -174,7 +174,7 @@ pub(crate) struct Logger {
impl Logger {
/// Creates a new logger with a filesystem writer. The parameters to this function
/// are the path to the log file, and the log level.
pub fn new_fs_writer(file_path: &str, level: LogLevel) -> Result<Self, ()> {
pub fn new_fs_writer(file_path: String, level: LogLevel) -> Result<Self, ()> {
if let Some(parent_dir) = Path::new(&file_path).parent() {
fs::create_dir_all(parent_dir)
.map_err(|e| eprintln!("ERROR: Failed to create log parent directory: {}", e))?;
Expand All@@ -187,7 +187,7 @@ impl Logger {
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
}

Ok(Self { writer: Writer::FileWriter { file_path: file_path.to_string(), level } })
Ok(Self { writer: Writer::FileWriter { file_path, level } })
}

pub fn new_log_facade(level: LogLevel) -> Self {
Expand Down
1 change: 1 addition & 0 deletions src/uniffi_types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ pub use crate::config::{
default_config, AnchorChannelsConfig, EsploraSyncConfig, MaxDustHTLCExposure,
};
pub use crate::graph::{ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo};
pub use crate::logger::{LogLevel, LogRecord, LogWriter};
pub use crate::payment::store::{
ConfirmationStatus, LSPFeeLimits, PaymentDirection, PaymentKind, PaymentStatus,
};
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

use persist::KVStoreWalletPersister;

use crate::logger::{log_debug, log_error, log_info, log_trace, Logger, LdkLogger};
use crate::logger::{log_debug, log_error, log_info, log_trace, LdkLogger, Logger};

use crate::fee_estimator::{ConfirmationTarget, FeeEstimator};
use crate::payment::store::{ConfirmationStatus, PaymentStore};
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Minor follow-ups to #407 by tnull · Pull Request #450 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 28 additions & 47 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILE_PATH, DEFAULT_LOG_LEVEL,
DEFAULT_STORAGE_DIR_PATH, WALLET_KEYS_SEED_LEN,
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL,
WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -111,18 +111,7 @@ impl Default for LiquiditySourceConfig {

#[derive(Clone)]
enum LogWriterConfig {
File {
/// The log file path.
///
/// This specifies the log file path if a destination other than the storage
/// directory, i.e. [`Config::storage_dir_path`], is preferred. If unconfigured,
/// defaults to [`DEFAULT_LOG_FILE_PATH`] in default storage directory.
log_file_path: Option<String>,
/// This specifies the log level.
///
/// If unconfigured, defaults to `Debug`.
log_level: Option<LogLevel>,
},
File { log_file_path: Option<String>, log_level: Option<LogLevel> },
Log(LogLevel),
Custom(Arc<dyn LogWriter>),
}
Expand All@@ -143,15 +132,6 @@ impl std::fmt::Debug for LogWriterConfig {
}
}

impl Default for LogWriterConfig {
fn default() -> Self {
Self::File {
log_file_path: Some(DEFAULT_LOG_FILE_PATH.to_string()),
log_level: Some(DEFAULT_LOG_LEVEL),
}
}
}

/// An error encountered during building a [`Node`].
///
/// [`Node`]: crate::Node
Expand DownExpand Up@@ -349,9 +329,11 @@ impl NodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILE_PATH`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&mut self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) -> &mut Self {
Expand DownExpand Up@@ -674,9 +656,11 @@ impl ArcedNodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILENAME`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) {
Expand DownExpand Up@@ -1317,34 +1301,31 @@ fn build_with_store_internal(
}

/// Sets up the node logger.
///
/// If `log_writer_conf` is set to None, uses [`LogWriterConfig::default()`].
/// The `node_conf` is provided to access the configured storage directory.
fn setup_logger(
log_writer_conf: &Option<LogWriterConfig>, node_conf: &Config,
log_writer_config: &Option<LogWriterConfig>, config: &Config,
) -> Result<Arc<Logger>, BuildError> {
let is_default = log_writer_conf.is_none();
let default_lw_config = LogWriterConfig::default();
let log_writer_config =
if let Some(conf) = log_writer_conf { conf } else { &default_lw_config };

let logger = match log_writer_config {
LogWriterConfig::File { log_file_path, log_level } => {
let fp = DEFAULT_LOG_FILE_PATH
.replace(DEFAULT_STORAGE_DIR_PATH, &node_conf.storage_dir_path);
let log_file_path =
if is_default { &fp } else { log_file_path.as_ref().map(|p| p).unwrap_or(&fp) };

let log_level = log_level.unwrap_or(DEFAULT_LOG_LEVEL);
Some(LogWriterConfig::File { log_file_path, log_level }) => {
let log_file_path = log_file_path
.clone()
.unwrap_or_else(|| format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME));
let log_level = log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL);

@arik-soarik-soJan 30, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how much we gain from using an or_else closure for a constant instead of or here.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, true


Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
LogWriterConfig::Log(log_level) => Logger::new_log_facade(*log_level),
Some(LogWriterConfig::Log(log_level)) => Logger::new_log_facade(*log_level),

LogWriterConfig::Custom(custom_log_writer) => {
Some(LogWriterConfig::Custom(custom_log_writer)) => {
Logger::new_custom_writer(Arc::clone(&custom_log_writer))
},
None => {
// Default to use `FileWriter`
let log_file_path = format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME);
let log_level = DEFAULT_LOG_LEVEL;
Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
};

Ok(Arc::new(logger))
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,8 +32,8 @@ const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS: u64 = 25_000;
/// The default log level.
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Debug;

/// The default log file path.
pub const DEFAULT_LOG_FILE_PATH: &'static str = "/tmp/ldk_node/ldk_node.log";
/// The default log file name.
pub const DEFAULT_LOG_FILENAME: &'static str = "ldk_node.log";

/// The default storage directory.
pub const DEFAULT_STORAGE_DIR_PATH: &str = "/tmp/ldk_node";
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -144,7 +144,6 @@ use types::{
pub use types::{ChannelDetails, CustomTlvRecord, PeerDetails, UserChannelId};

use logger::{log_error, log_info, log_trace, LdkLogger, Logger};
pub use logger::{LogLevel, LogRecord, LogWriter};

use lightning::chain::BestBlock;
use lightning::events::bump_transaction::Wallet as LdkWallet;
Expand Down
12 changes: 6 additions & 6 deletions src/logger.rs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how cargo fmt didn't catch that?

@tnulltnullJan 30, 2025

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t touch macros.

Original file line numberDiff line numberDiff line change
Expand Up@@ -143,10 +143,10 @@ impl LogWriter for Writer {
($log_level:expr, $($args:tt)*) => {
match $log_level {
LogLevel::Gossip | LogLevel::Trace => trace!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
}
};
}
Expand DownExpand Up@@ -174,7 +174,7 @@ pub(crate) struct Logger {
impl Logger {
/// Creates a new logger with a filesystem writer. The parameters to this function
/// are the path to the log file, and the log level.
pub fn new_fs_writer(file_path: &str, level: LogLevel) -> Result<Self, ()> {
pub fn new_fs_writer(file_path: String, level: LogLevel) -> Result<Self, ()> {
if let Some(parent_dir) = Path::new(&file_path).parent() {
fs::create_dir_all(parent_dir)
.map_err(|e| eprintln!("ERROR: Failed to create log parent directory: {}", e))?;
Expand All@@ -187,7 +187,7 @@ impl Logger {
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
}

Ok(Self { writer: Writer::FileWriter { file_path: file_path.to_string(), level } })
Ok(Self { writer: Writer::FileWriter { file_path, level } })
}

pub fn new_log_facade(level: LogLevel) -> Self {
Expand Down
1 change: 1 addition & 0 deletions src/uniffi_types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ pub use crate::config::{
default_config, AnchorChannelsConfig, EsploraSyncConfig, MaxDustHTLCExposure,
};
pub use crate::graph::{ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo};
pub use crate::logger::{LogLevel, LogRecord, LogWriter};
pub use crate::payment::store::{
ConfirmationStatus, LSPFeeLimits, PaymentDirection, PaymentKind, PaymentStatus,
};
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

use persist::KVStoreWalletPersister;

use crate::logger::{log_debug, log_error, log_info, log_trace, Logger, LdkLogger};
use crate::logger::{log_debug, log_error, log_info, log_trace, LdkLogger, Logger};

use crate::fee_estimator::{ConfirmationTarget, FeeEstimator};
use crate::payment::store::{ConfirmationStatus, PaymentStore};
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Minor follow-ups to #407 by tnull · Pull Request #450 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 28 additions & 47 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILE_PATH, DEFAULT_LOG_LEVEL,
DEFAULT_STORAGE_DIR_PATH, WALLET_KEYS_SEED_LEN,
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL,
WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -111,18 +111,7 @@ impl Default for LiquiditySourceConfig {

#[derive(Clone)]
enum LogWriterConfig {
File {
/// The log file path.
///
/// This specifies the log file path if a destination other than the storage
/// directory, i.e. [`Config::storage_dir_path`], is preferred. If unconfigured,
/// defaults to [`DEFAULT_LOG_FILE_PATH`] in default storage directory.
log_file_path: Option<String>,
/// This specifies the log level.
///
/// If unconfigured, defaults to `Debug`.
log_level: Option<LogLevel>,
},
File { log_file_path: Option<String>, log_level: Option<LogLevel> },
Log(LogLevel),
Custom(Arc<dyn LogWriter>),
}
Expand All@@ -143,15 +132,6 @@ impl std::fmt::Debug for LogWriterConfig {
}
}

impl Default for LogWriterConfig {
fn default() -> Self {
Self::File {
log_file_path: Some(DEFAULT_LOG_FILE_PATH.to_string()),
log_level: Some(DEFAULT_LOG_LEVEL),
}
}
}

/// An error encountered during building a [`Node`].
///
/// [`Node`]: crate::Node
Expand DownExpand Up@@ -349,9 +329,11 @@ impl NodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILE_PATH`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&mut self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) -> &mut Self {
Expand DownExpand Up@@ -674,9 +656,11 @@ impl ArcedNodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILENAME`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) {
Expand DownExpand Up@@ -1317,34 +1301,31 @@ fn build_with_store_internal(
}

/// Sets up the node logger.
///
/// If `log_writer_conf` is set to None, uses [`LogWriterConfig::default()`].
/// The `node_conf` is provided to access the configured storage directory.
fn setup_logger(
log_writer_conf: &Option<LogWriterConfig>, node_conf: &Config,
log_writer_config: &Option<LogWriterConfig>, config: &Config,
) -> Result<Arc<Logger>, BuildError> {
let is_default = log_writer_conf.is_none();
let default_lw_config = LogWriterConfig::default();
let log_writer_config =
if let Some(conf) = log_writer_conf { conf } else { &default_lw_config };

let logger = match log_writer_config {
LogWriterConfig::File { log_file_path, log_level } => {
let fp = DEFAULT_LOG_FILE_PATH
.replace(DEFAULT_STORAGE_DIR_PATH, &node_conf.storage_dir_path);
let log_file_path =
if is_default { &fp } else { log_file_path.as_ref().map(|p| p).unwrap_or(&fp) };

let log_level = log_level.unwrap_or(DEFAULT_LOG_LEVEL);
Some(LogWriterConfig::File { log_file_path, log_level }) => {
let log_file_path = log_file_path
.clone()
.unwrap_or_else(|| format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME));
let log_level = log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL);

@arik-soarik-soJan 30, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how much we gain from using an or_else closure for a constant instead of or here.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, true


Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
LogWriterConfig::Log(log_level) => Logger::new_log_facade(*log_level),
Some(LogWriterConfig::Log(log_level)) => Logger::new_log_facade(*log_level),

LogWriterConfig::Custom(custom_log_writer) => {
Some(LogWriterConfig::Custom(custom_log_writer)) => {
Logger::new_custom_writer(Arc::clone(&custom_log_writer))
},
None => {
// Default to use `FileWriter`
let log_file_path = format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME);
let log_level = DEFAULT_LOG_LEVEL;
Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
};

Ok(Arc::new(logger))
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,8 +32,8 @@ const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS: u64 = 25_000;
/// The default log level.
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Debug;

/// The default log file path.
pub const DEFAULT_LOG_FILE_PATH: &'static str = "/tmp/ldk_node/ldk_node.log";
/// The default log file name.
pub const DEFAULT_LOG_FILENAME: &'static str = "ldk_node.log";

/// The default storage directory.
pub const DEFAULT_STORAGE_DIR_PATH: &str = "/tmp/ldk_node";
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -144,7 +144,6 @@ use types::{
pub use types::{ChannelDetails, CustomTlvRecord, PeerDetails, UserChannelId};

use logger::{log_error, log_info, log_trace, LdkLogger, Logger};
pub use logger::{LogLevel, LogRecord, LogWriter};

use lightning::chain::BestBlock;
use lightning::events::bump_transaction::Wallet as LdkWallet;
Expand Down
12 changes: 6 additions & 6 deletions src/logger.rs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how cargo fmt didn't catch that?

@tnulltnullJan 30, 2025

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t touch macros.

Original file line numberDiff line numberDiff line change
Expand Up@@ -143,10 +143,10 @@ impl LogWriter for Writer {
($log_level:expr, $($args:tt)*) => {
match $log_level {
LogLevel::Gossip | LogLevel::Trace => trace!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
}
};
}
Expand DownExpand Up@@ -174,7 +174,7 @@ pub(crate) struct Logger {
impl Logger {
/// Creates a new logger with a filesystem writer. The parameters to this function
/// are the path to the log file, and the log level.
pub fn new_fs_writer(file_path: &str, level: LogLevel) -> Result<Self, ()> {
pub fn new_fs_writer(file_path: String, level: LogLevel) -> Result<Self, ()> {
if let Some(parent_dir) = Path::new(&file_path).parent() {
fs::create_dir_all(parent_dir)
.map_err(|e| eprintln!("ERROR: Failed to create log parent directory: {}", e))?;
Expand All@@ -187,7 +187,7 @@ impl Logger {
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
}

Ok(Self { writer: Writer::FileWriter { file_path: file_path.to_string(), level } })
Ok(Self { writer: Writer::FileWriter { file_path, level } })
}

pub fn new_log_facade(level: LogLevel) -> Self {
Expand Down
1 change: 1 addition & 0 deletions src/uniffi_types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ pub use crate::config::{
default_config, AnchorChannelsConfig, EsploraSyncConfig, MaxDustHTLCExposure,
};
pub use crate::graph::{ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo};
pub use crate::logger::{LogLevel, LogRecord, LogWriter};
pub use crate::payment::store::{
ConfirmationStatus, LSPFeeLimits, PaymentDirection, PaymentKind, PaymentStatus,
};
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

use persist::KVStoreWalletPersister;

use crate::logger::{log_debug, log_error, log_info, log_trace, Logger, LdkLogger};
use crate::logger::{log_debug, log_error, log_info, log_trace, LdkLogger, Logger};

use crate::fee_estimator::{ConfirmationTarget, FeeEstimator};
use crate::payment::store::{ConfirmationStatus, PaymentStore};
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Minor follow-ups to #407 by tnull · Pull Request #450 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 28 additions & 47 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILE_PATH, DEFAULT_LOG_LEVEL,
DEFAULT_STORAGE_DIR_PATH, WALLET_KEYS_SEED_LEN,
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL,
WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -111,18 +111,7 @@ impl Default for LiquiditySourceConfig {

#[derive(Clone)]
enum LogWriterConfig {
File {
/// The log file path.
///
/// This specifies the log file path if a destination other than the storage
/// directory, i.e. [`Config::storage_dir_path`], is preferred. If unconfigured,
/// defaults to [`DEFAULT_LOG_FILE_PATH`] in default storage directory.
log_file_path: Option<String>,
/// This specifies the log level.
///
/// If unconfigured, defaults to `Debug`.
log_level: Option<LogLevel>,
},
File { log_file_path: Option<String>, log_level: Option<LogLevel> },
Log(LogLevel),
Custom(Arc<dyn LogWriter>),
}
Expand All@@ -143,15 +132,6 @@ impl std::fmt::Debug for LogWriterConfig {
}
}

impl Default for LogWriterConfig {
fn default() -> Self {
Self::File {
log_file_path: Some(DEFAULT_LOG_FILE_PATH.to_string()),
log_level: Some(DEFAULT_LOG_LEVEL),
}
}
}

/// An error encountered during building a [`Node`].
///
/// [`Node`]: crate::Node
Expand DownExpand Up@@ -349,9 +329,11 @@ impl NodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILE_PATH`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&mut self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) -> &mut Self {
Expand DownExpand Up@@ -674,9 +656,11 @@ impl ArcedNodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILENAME`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) {
Expand DownExpand Up@@ -1317,34 +1301,31 @@ fn build_with_store_internal(
}

/// Sets up the node logger.
///
/// If `log_writer_conf` is set to None, uses [`LogWriterConfig::default()`].
/// The `node_conf` is provided to access the configured storage directory.
fn setup_logger(
log_writer_conf: &Option<LogWriterConfig>, node_conf: &Config,
log_writer_config: &Option<LogWriterConfig>, config: &Config,
) -> Result<Arc<Logger>, BuildError> {
let is_default = log_writer_conf.is_none();
let default_lw_config = LogWriterConfig::default();
let log_writer_config =
if let Some(conf) = log_writer_conf { conf } else { &default_lw_config };

let logger = match log_writer_config {
LogWriterConfig::File { log_file_path, log_level } => {
let fp = DEFAULT_LOG_FILE_PATH
.replace(DEFAULT_STORAGE_DIR_PATH, &node_conf.storage_dir_path);
let log_file_path =
if is_default { &fp } else { log_file_path.as_ref().map(|p| p).unwrap_or(&fp) };

let log_level = log_level.unwrap_or(DEFAULT_LOG_LEVEL);
Some(LogWriterConfig::File { log_file_path, log_level }) => {
let log_file_path = log_file_path
.clone()
.unwrap_or_else(|| format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME));
let log_level = log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL);

@arik-soarik-soJan 30, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how much we gain from using an or_else closure for a constant instead of or here.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, true


Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
LogWriterConfig::Log(log_level) => Logger::new_log_facade(*log_level),
Some(LogWriterConfig::Log(log_level)) => Logger::new_log_facade(*log_level),

LogWriterConfig::Custom(custom_log_writer) => {
Some(LogWriterConfig::Custom(custom_log_writer)) => {
Logger::new_custom_writer(Arc::clone(&custom_log_writer))
},
None => {
// Default to use `FileWriter`
let log_file_path = format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME);
let log_level = DEFAULT_LOG_LEVEL;
Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
};

Ok(Arc::new(logger))
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,8 +32,8 @@ const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS: u64 = 25_000;
/// The default log level.
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Debug;

/// The default log file path.
pub const DEFAULT_LOG_FILE_PATH: &'static str = "/tmp/ldk_node/ldk_node.log";
/// The default log file name.
pub const DEFAULT_LOG_FILENAME: &'static str = "ldk_node.log";

/// The default storage directory.
pub const DEFAULT_STORAGE_DIR_PATH: &str = "/tmp/ldk_node";
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -144,7 +144,6 @@ use types::{
pub use types::{ChannelDetails, CustomTlvRecord, PeerDetails, UserChannelId};

use logger::{log_error, log_info, log_trace, LdkLogger, Logger};
pub use logger::{LogLevel, LogRecord, LogWriter};

use lightning::chain::BestBlock;
use lightning::events::bump_transaction::Wallet as LdkWallet;
Expand Down
12 changes: 6 additions & 6 deletions src/logger.rs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how cargo fmt didn't catch that?

@tnulltnullJan 30, 2025

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t touch macros.

Original file line numberDiff line numberDiff line change
Expand Up@@ -143,10 +143,10 @@ impl LogWriter for Writer {
($log_level:expr, $($args:tt)*) => {
match $log_level {
LogLevel::Gossip | LogLevel::Trace => trace!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
}
};
}
Expand DownExpand Up@@ -174,7 +174,7 @@ pub(crate) struct Logger {
impl Logger {
/// Creates a new logger with a filesystem writer. The parameters to this function
/// are the path to the log file, and the log level.
pub fn new_fs_writer(file_path: &str, level: LogLevel) -> Result<Self, ()> {
pub fn new_fs_writer(file_path: String, level: LogLevel) -> Result<Self, ()> {
if let Some(parent_dir) = Path::new(&file_path).parent() {
fs::create_dir_all(parent_dir)
.map_err(|e| eprintln!("ERROR: Failed to create log parent directory: {}", e))?;
Expand All@@ -187,7 +187,7 @@ impl Logger {
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
}

Ok(Self { writer: Writer::FileWriter { file_path: file_path.to_string(), level } })
Ok(Self { writer: Writer::FileWriter { file_path, level } })
}

pub fn new_log_facade(level: LogLevel) -> Self {
Expand Down
1 change: 1 addition & 0 deletions src/uniffi_types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ pub use crate::config::{
default_config, AnchorChannelsConfig, EsploraSyncConfig, MaxDustHTLCExposure,
};
pub use crate::graph::{ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo};
pub use crate::logger::{LogLevel, LogRecord, LogWriter};
pub use crate::payment::store::{
ConfirmationStatus, LSPFeeLimits, PaymentDirection, PaymentKind, PaymentStatus,
};
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

use persist::KVStoreWalletPersister;

use crate::logger::{log_debug, log_error, log_info, log_trace, Logger, LdkLogger};
use crate::logger::{log_debug, log_error, log_info, log_trace, LdkLogger, Logger};

use crate::fee_estimator::{ConfirmationTarget, FeeEstimator};
use crate::payment::store::{ConfirmationStatus, PaymentStore};
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Minor follow-ups to #407 by tnull · Pull Request #450 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 28 additions & 47 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILE_PATH, DEFAULT_LOG_LEVEL,
DEFAULT_STORAGE_DIR_PATH, WALLET_KEYS_SEED_LEN,
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL,
WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -111,18 +111,7 @@ impl Default for LiquiditySourceConfig {

#[derive(Clone)]
enum LogWriterConfig {
File {
/// The log file path.
///
/// This specifies the log file path if a destination other than the storage
/// directory, i.e. [`Config::storage_dir_path`], is preferred. If unconfigured,
/// defaults to [`DEFAULT_LOG_FILE_PATH`] in default storage directory.
log_file_path: Option<String>,
/// This specifies the log level.
///
/// If unconfigured, defaults to `Debug`.
log_level: Option<LogLevel>,
},
File { log_file_path: Option<String>, log_level: Option<LogLevel> },
Log(LogLevel),
Custom(Arc<dyn LogWriter>),
}
Expand All@@ -143,15 +132,6 @@ impl std::fmt::Debug for LogWriterConfig {
}
}

impl Default for LogWriterConfig {
fn default() -> Self {
Self::File {
log_file_path: Some(DEFAULT_LOG_FILE_PATH.to_string()),
log_level: Some(DEFAULT_LOG_LEVEL),
}
}
}

/// An error encountered during building a [`Node`].
///
/// [`Node`]: crate::Node
Expand DownExpand Up@@ -349,9 +329,11 @@ impl NodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILE_PATH`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&mut self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) -> &mut Self {
Expand DownExpand Up@@ -674,9 +656,11 @@ impl ArcedNodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILENAME`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) {
Expand DownExpand Up@@ -1317,34 +1301,31 @@ fn build_with_store_internal(
}

/// Sets up the node logger.
///
/// If `log_writer_conf` is set to None, uses [`LogWriterConfig::default()`].
/// The `node_conf` is provided to access the configured storage directory.
fn setup_logger(
log_writer_conf: &Option<LogWriterConfig>, node_conf: &Config,
log_writer_config: &Option<LogWriterConfig>, config: &Config,
) -> Result<Arc<Logger>, BuildError> {
let is_default = log_writer_conf.is_none();
let default_lw_config = LogWriterConfig::default();
let log_writer_config =
if let Some(conf) = log_writer_conf { conf } else { &default_lw_config };

let logger = match log_writer_config {
LogWriterConfig::File { log_file_path, log_level } => {
let fp = DEFAULT_LOG_FILE_PATH
.replace(DEFAULT_STORAGE_DIR_PATH, &node_conf.storage_dir_path);
let log_file_path =
if is_default { &fp } else { log_file_path.as_ref().map(|p| p).unwrap_or(&fp) };

let log_level = log_level.unwrap_or(DEFAULT_LOG_LEVEL);
Some(LogWriterConfig::File { log_file_path, log_level }) => {
let log_file_path = log_file_path
.clone()
.unwrap_or_else(|| format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME));
let log_level = log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL);

@arik-soarik-soJan 30, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how much we gain from using an or_else closure for a constant instead of or here.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, true


Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
LogWriterConfig::Log(log_level) => Logger::new_log_facade(*log_level),
Some(LogWriterConfig::Log(log_level)) => Logger::new_log_facade(*log_level),

LogWriterConfig::Custom(custom_log_writer) => {
Some(LogWriterConfig::Custom(custom_log_writer)) => {
Logger::new_custom_writer(Arc::clone(&custom_log_writer))
},
None => {
// Default to use `FileWriter`
let log_file_path = format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME);
let log_level = DEFAULT_LOG_LEVEL;
Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
};

Ok(Arc::new(logger))
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,8 +32,8 @@ const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS: u64 = 25_000;
/// The default log level.
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Debug;

/// The default log file path.
pub const DEFAULT_LOG_FILE_PATH: &'static str = "/tmp/ldk_node/ldk_node.log";
/// The default log file name.
pub const DEFAULT_LOG_FILENAME: &'static str = "ldk_node.log";

/// The default storage directory.
pub const DEFAULT_STORAGE_DIR_PATH: &str = "/tmp/ldk_node";
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -144,7 +144,6 @@ use types::{
pub use types::{ChannelDetails, CustomTlvRecord, PeerDetails, UserChannelId};

use logger::{log_error, log_info, log_trace, LdkLogger, Logger};
pub use logger::{LogLevel, LogRecord, LogWriter};

use lightning::chain::BestBlock;
use lightning::events::bump_transaction::Wallet as LdkWallet;
Expand Down
12 changes: 6 additions & 6 deletions src/logger.rs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how cargo fmt didn't catch that?

@tnulltnullJan 30, 2025

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t touch macros.

Original file line numberDiff line numberDiff line change
Expand Up@@ -143,10 +143,10 @@ impl LogWriter for Writer {
($log_level:expr, $($args:tt)*) => {
match $log_level {
LogLevel::Gossip | LogLevel::Trace => trace!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
}
};
}
Expand DownExpand Up@@ -174,7 +174,7 @@ pub(crate) struct Logger {
impl Logger {
/// Creates a new logger with a filesystem writer. The parameters to this function
/// are the path to the log file, and the log level.
pub fn new_fs_writer(file_path: &str, level: LogLevel) -> Result<Self, ()> {
pub fn new_fs_writer(file_path: String, level: LogLevel) -> Result<Self, ()> {
if let Some(parent_dir) = Path::new(&file_path).parent() {
fs::create_dir_all(parent_dir)
.map_err(|e| eprintln!("ERROR: Failed to create log parent directory: {}", e))?;
Expand All@@ -187,7 +187,7 @@ impl Logger {
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
}

Ok(Self { writer: Writer::FileWriter { file_path: file_path.to_string(), level } })
Ok(Self { writer: Writer::FileWriter { file_path, level } })
}

pub fn new_log_facade(level: LogLevel) -> Self {
Expand Down
1 change: 1 addition & 0 deletions src/uniffi_types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ pub use crate::config::{
default_config, AnchorChannelsConfig, EsploraSyncConfig, MaxDustHTLCExposure,
};
pub use crate::graph::{ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo};
pub use crate::logger::{LogLevel, LogRecord, LogWriter};
pub use crate::payment::store::{
ConfirmationStatus, LSPFeeLimits, PaymentDirection, PaymentKind, PaymentStatus,
};
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

use persist::KVStoreWalletPersister;

use crate::logger::{log_debug, log_error, log_info, log_trace, Logger, LdkLogger};
use crate::logger::{log_debug, log_error, log_info, log_trace, LdkLogger, Logger};

use crate::fee_estimator::{ConfirmationTarget, FeeEstimator};
use crate::payment::store::{ConfirmationStatus, PaymentStore};
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Minor follow-ups to #407 by tnull · Pull Request #450 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 28 additions & 47 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILE_PATH, DEFAULT_LOG_LEVEL,
DEFAULT_STORAGE_DIR_PATH, WALLET_KEYS_SEED_LEN,
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL,
WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -111,18 +111,7 @@ impl Default for LiquiditySourceConfig {

#[derive(Clone)]
enum LogWriterConfig {
File {
/// The log file path.
///
/// This specifies the log file path if a destination other than the storage
/// directory, i.e. [`Config::storage_dir_path`], is preferred. If unconfigured,
/// defaults to [`DEFAULT_LOG_FILE_PATH`] in default storage directory.
log_file_path: Option<String>,
/// This specifies the log level.
///
/// If unconfigured, defaults to `Debug`.
log_level: Option<LogLevel>,
},
File { log_file_path: Option<String>, log_level: Option<LogLevel> },
Log(LogLevel),
Custom(Arc<dyn LogWriter>),
}
Expand All@@ -143,15 +132,6 @@ impl std::fmt::Debug for LogWriterConfig {
}
}

impl Default for LogWriterConfig {
fn default() -> Self {
Self::File {
log_file_path: Some(DEFAULT_LOG_FILE_PATH.to_string()),
log_level: Some(DEFAULT_LOG_LEVEL),
}
}
}

/// An error encountered during building a [`Node`].
///
/// [`Node`]: crate::Node
Expand DownExpand Up@@ -349,9 +329,11 @@ impl NodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILE_PATH`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&mut self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) -> &mut Self {
Expand DownExpand Up@@ -674,9 +656,11 @@ impl ArcedNodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILENAME`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) {
Expand DownExpand Up@@ -1317,34 +1301,31 @@ fn build_with_store_internal(
}

/// Sets up the node logger.
///
/// If `log_writer_conf` is set to None, uses [`LogWriterConfig::default()`].
/// The `node_conf` is provided to access the configured storage directory.
fn setup_logger(
log_writer_conf: &Option<LogWriterConfig>, node_conf: &Config,
log_writer_config: &Option<LogWriterConfig>, config: &Config,
) -> Result<Arc<Logger>, BuildError> {
let is_default = log_writer_conf.is_none();
let default_lw_config = LogWriterConfig::default();
let log_writer_config =
if let Some(conf) = log_writer_conf { conf } else { &default_lw_config };

let logger = match log_writer_config {
LogWriterConfig::File { log_file_path, log_level } => {
let fp = DEFAULT_LOG_FILE_PATH
.replace(DEFAULT_STORAGE_DIR_PATH, &node_conf.storage_dir_path);
let log_file_path =
if is_default { &fp } else { log_file_path.as_ref().map(|p| p).unwrap_or(&fp) };

let log_level = log_level.unwrap_or(DEFAULT_LOG_LEVEL);
Some(LogWriterConfig::File { log_file_path, log_level }) => {
let log_file_path = log_file_path
.clone()
.unwrap_or_else(|| format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME));
let log_level = log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL);

@arik-soarik-soJan 30, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how much we gain from using an or_else closure for a constant instead of or here.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, true


Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
LogWriterConfig::Log(log_level) => Logger::new_log_facade(*log_level),
Some(LogWriterConfig::Log(log_level)) => Logger::new_log_facade(*log_level),

LogWriterConfig::Custom(custom_log_writer) => {
Some(LogWriterConfig::Custom(custom_log_writer)) => {
Logger::new_custom_writer(Arc::clone(&custom_log_writer))
},
None => {
// Default to use `FileWriter`
let log_file_path = format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME);
let log_level = DEFAULT_LOG_LEVEL;
Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
};

Ok(Arc::new(logger))
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,8 +32,8 @@ const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS: u64 = 25_000;
/// The default log level.
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Debug;

/// The default log file path.
pub const DEFAULT_LOG_FILE_PATH: &'static str = "/tmp/ldk_node/ldk_node.log";
/// The default log file name.
pub const DEFAULT_LOG_FILENAME: &'static str = "ldk_node.log";

/// The default storage directory.
pub const DEFAULT_STORAGE_DIR_PATH: &str = "/tmp/ldk_node";
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -144,7 +144,6 @@ use types::{
pub use types::{ChannelDetails, CustomTlvRecord, PeerDetails, UserChannelId};

use logger::{log_error, log_info, log_trace, LdkLogger, Logger};
pub use logger::{LogLevel, LogRecord, LogWriter};

use lightning::chain::BestBlock;
use lightning::events::bump_transaction::Wallet as LdkWallet;
Expand Down
12 changes: 6 additions & 6 deletions src/logger.rs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how cargo fmt didn't catch that?

@tnulltnullJan 30, 2025

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t touch macros.

Original file line numberDiff line numberDiff line change
Expand Up@@ -143,10 +143,10 @@ impl LogWriter for Writer {
($log_level:expr, $($args:tt)*) => {
match $log_level {
LogLevel::Gossip | LogLevel::Trace => trace!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
}
};
}
Expand DownExpand Up@@ -174,7 +174,7 @@ pub(crate) struct Logger {
impl Logger {
/// Creates a new logger with a filesystem writer. The parameters to this function
/// are the path to the log file, and the log level.
pub fn new_fs_writer(file_path: &str, level: LogLevel) -> Result<Self, ()> {
pub fn new_fs_writer(file_path: String, level: LogLevel) -> Result<Self, ()> {
if let Some(parent_dir) = Path::new(&file_path).parent() {
fs::create_dir_all(parent_dir)
.map_err(|e| eprintln!("ERROR: Failed to create log parent directory: {}", e))?;
Expand All@@ -187,7 +187,7 @@ impl Logger {
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
}

Ok(Self { writer: Writer::FileWriter { file_path: file_path.to_string(), level } })
Ok(Self { writer: Writer::FileWriter { file_path, level } })
}

pub fn new_log_facade(level: LogLevel) -> Self {
Expand Down
1 change: 1 addition & 0 deletions src/uniffi_types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ pub use crate::config::{
default_config, AnchorChannelsConfig, EsploraSyncConfig, MaxDustHTLCExposure,
};
pub use crate::graph::{ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo};
pub use crate::logger::{LogLevel, LogRecord, LogWriter};
pub use crate::payment::store::{
ConfirmationStatus, LSPFeeLimits, PaymentDirection, PaymentKind, PaymentStatus,
};
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

use persist::KVStoreWalletPersister;

use crate::logger::{log_debug, log_error, log_info, log_trace, Logger, LdkLogger};
use crate::logger::{log_debug, log_error, log_info, log_trace, LdkLogger, Logger};

use crate::fee_estimator::{ConfirmationTarget, FeeEstimator};
use crate::payment::store::{ConfirmationStatus, PaymentStore};
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Minor follow-ups to #407 by tnull · Pull Request #450 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 28 additions & 47 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILE_PATH, DEFAULT_LOG_LEVEL,
DEFAULT_STORAGE_DIR_PATH, WALLET_KEYS_SEED_LEN,
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL,
WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -111,18 +111,7 @@ impl Default for LiquiditySourceConfig {

#[derive(Clone)]
enum LogWriterConfig {
File {
/// The log file path.
///
/// This specifies the log file path if a destination other than the storage
/// directory, i.e. [`Config::storage_dir_path`], is preferred. If unconfigured,
/// defaults to [`DEFAULT_LOG_FILE_PATH`] in default storage directory.
log_file_path: Option<String>,
/// This specifies the log level.
///
/// If unconfigured, defaults to `Debug`.
log_level: Option<LogLevel>,
},
File { log_file_path: Option<String>, log_level: Option<LogLevel> },
Log(LogLevel),
Custom(Arc<dyn LogWriter>),
}
Expand All@@ -143,15 +132,6 @@ impl std::fmt::Debug for LogWriterConfig {
}
}

impl Default for LogWriterConfig {
fn default() -> Self {
Self::File {
log_file_path: Some(DEFAULT_LOG_FILE_PATH.to_string()),
log_level: Some(DEFAULT_LOG_LEVEL),
}
}
}

/// An error encountered during building a [`Node`].
///
/// [`Node`]: crate::Node
Expand DownExpand Up@@ -349,9 +329,11 @@ impl NodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILE_PATH`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&mut self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) -> &mut Self {
Expand DownExpand Up@@ -674,9 +656,11 @@ impl ArcedNodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILENAME`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) {
Expand DownExpand Up@@ -1317,34 +1301,31 @@ fn build_with_store_internal(
}

/// Sets up the node logger.
///
/// If `log_writer_conf` is set to None, uses [`LogWriterConfig::default()`].
/// The `node_conf` is provided to access the configured storage directory.
fn setup_logger(
log_writer_conf: &Option<LogWriterConfig>, node_conf: &Config,
log_writer_config: &Option<LogWriterConfig>, config: &Config,
) -> Result<Arc<Logger>, BuildError> {
let is_default = log_writer_conf.is_none();
let default_lw_config = LogWriterConfig::default();
let log_writer_config =
if let Some(conf) = log_writer_conf { conf } else { &default_lw_config };

let logger = match log_writer_config {
LogWriterConfig::File { log_file_path, log_level } => {
let fp = DEFAULT_LOG_FILE_PATH
.replace(DEFAULT_STORAGE_DIR_PATH, &node_conf.storage_dir_path);
let log_file_path =
if is_default { &fp } else { log_file_path.as_ref().map(|p| p).unwrap_or(&fp) };

let log_level = log_level.unwrap_or(DEFAULT_LOG_LEVEL);
Some(LogWriterConfig::File { log_file_path, log_level }) => {
let log_file_path = log_file_path
.clone()
.unwrap_or_else(|| format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME));
let log_level = log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL);

@arik-soarik-soJan 30, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how much we gain from using an or_else closure for a constant instead of or here.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, true


Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
LogWriterConfig::Log(log_level) => Logger::new_log_facade(*log_level),
Some(LogWriterConfig::Log(log_level)) => Logger::new_log_facade(*log_level),

LogWriterConfig::Custom(custom_log_writer) => {
Some(LogWriterConfig::Custom(custom_log_writer)) => {
Logger::new_custom_writer(Arc::clone(&custom_log_writer))
},
None => {
// Default to use `FileWriter`
let log_file_path = format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME);
let log_level = DEFAULT_LOG_LEVEL;
Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
};

Ok(Arc::new(logger))
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,8 +32,8 @@ const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS: u64 = 25_000;
/// The default log level.
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Debug;

/// The default log file path.
pub const DEFAULT_LOG_FILE_PATH: &'static str = "/tmp/ldk_node/ldk_node.log";
/// The default log file name.
pub const DEFAULT_LOG_FILENAME: &'static str = "ldk_node.log";

/// The default storage directory.
pub const DEFAULT_STORAGE_DIR_PATH: &str = "/tmp/ldk_node";
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -144,7 +144,6 @@ use types::{
pub use types::{ChannelDetails, CustomTlvRecord, PeerDetails, UserChannelId};

use logger::{log_error, log_info, log_trace, LdkLogger, Logger};
pub use logger::{LogLevel, LogRecord, LogWriter};

use lightning::chain::BestBlock;
use lightning::events::bump_transaction::Wallet as LdkWallet;
Expand Down
12 changes: 6 additions & 6 deletions src/logger.rs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how cargo fmt didn't catch that?

@tnulltnullJan 30, 2025

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t touch macros.

Original file line numberDiff line numberDiff line change
Expand Up@@ -143,10 +143,10 @@ impl LogWriter for Writer {
($log_level:expr, $($args:tt)*) => {
match $log_level {
LogLevel::Gossip | LogLevel::Trace => trace!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
}
};
}
Expand DownExpand Up@@ -174,7 +174,7 @@ pub(crate) struct Logger {
impl Logger {
/// Creates a new logger with a filesystem writer. The parameters to this function
/// are the path to the log file, and the log level.
pub fn new_fs_writer(file_path: &str, level: LogLevel) -> Result<Self, ()> {
pub fn new_fs_writer(file_path: String, level: LogLevel) -> Result<Self, ()> {
if let Some(parent_dir) = Path::new(&file_path).parent() {
fs::create_dir_all(parent_dir)
.map_err(|e| eprintln!("ERROR: Failed to create log parent directory: {}", e))?;
Expand All@@ -187,7 +187,7 @@ impl Logger {
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
}

Ok(Self { writer: Writer::FileWriter { file_path: file_path.to_string(), level } })
Ok(Self { writer: Writer::FileWriter { file_path, level } })
}

pub fn new_log_facade(level: LogLevel) -> Self {
Expand Down
1 change: 1 addition & 0 deletions src/uniffi_types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ pub use crate::config::{
default_config, AnchorChannelsConfig, EsploraSyncConfig, MaxDustHTLCExposure,
};
pub use crate::graph::{ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo};
pub use crate::logger::{LogLevel, LogRecord, LogWriter};
pub use crate::payment::store::{
ConfirmationStatus, LSPFeeLimits, PaymentDirection, PaymentKind, PaymentStatus,
};
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

use persist::KVStoreWalletPersister;

use crate::logger::{log_debug, log_error, log_info, log_trace, Logger, LdkLogger};
use crate::logger::{log_debug, log_error, log_info, log_trace, LdkLogger, Logger};

use crate::fee_estimator::{ConfirmationTarget, FeeEstimator};
use crate::payment::store::{ConfirmationStatus, PaymentStore};
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Minor follow-ups to #407 by tnull · Pull Request #450 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 28 additions & 47 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILE_PATH, DEFAULT_LOG_LEVEL,
DEFAULT_STORAGE_DIR_PATH, WALLET_KEYS_SEED_LEN,
default_user_config, Config, EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL,
WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -111,18 +111,7 @@ impl Default for LiquiditySourceConfig {

#[derive(Clone)]
enum LogWriterConfig {
File {
/// The log file path.
///
/// This specifies the log file path if a destination other than the storage
/// directory, i.e. [`Config::storage_dir_path`], is preferred. If unconfigured,
/// defaults to [`DEFAULT_LOG_FILE_PATH`] in default storage directory.
log_file_path: Option<String>,
/// This specifies the log level.
///
/// If unconfigured, defaults to `Debug`.
log_level: Option<LogLevel>,
},
File { log_file_path: Option<String>, log_level: Option<LogLevel> },
Log(LogLevel),
Custom(Arc<dyn LogWriter>),
}
Expand All@@ -143,15 +132,6 @@ impl std::fmt::Debug for LogWriterConfig {
}
}

impl Default for LogWriterConfig {
fn default() -> Self {
Self::File {
log_file_path: Some(DEFAULT_LOG_FILE_PATH.to_string()),
log_level: Some(DEFAULT_LOG_LEVEL),
}
}
}

/// An error encountered during building a [`Node`].
///
/// [`Node`]: crate::Node
Expand DownExpand Up@@ -349,9 +329,11 @@ impl NodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILE_PATH`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&mut self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) -> &mut Self {
Expand DownExpand Up@@ -674,9 +656,11 @@ impl ArcedNodeBuilder {

/// Configures the [`Node`] instance to write logs to the filesystem.
///
/// The `log_file_path` defaults to the [`DEFAULT_LOG_FILENAME`] in the default
/// storage directory if set to None.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to None.
/// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
/// [`Config::storage_dir_path`] if set to `None`.
/// The `log_level` defaults to [`DEFAULT_LOG_LEVEL`] if set to `None`.
///
/// [`DEFAULT_LOG_FILENAME`]: crate::config::DEFAULT_LOG_FILENAME
pub fn set_filesystem_logger(
&self, log_file_path: Option<String>, log_level: Option<LogLevel>,
) {
Expand DownExpand Up@@ -1317,34 +1301,31 @@ fn build_with_store_internal(
}

/// Sets up the node logger.
///
/// If `log_writer_conf` is set to None, uses [`LogWriterConfig::default()`].
/// The `node_conf` is provided to access the configured storage directory.
fn setup_logger(
log_writer_conf: &Option<LogWriterConfig>, node_conf: &Config,
log_writer_config: &Option<LogWriterConfig>, config: &Config,
) -> Result<Arc<Logger>, BuildError> {
let is_default = log_writer_conf.is_none();
let default_lw_config = LogWriterConfig::default();
let log_writer_config =
if let Some(conf) = log_writer_conf { conf } else { &default_lw_config };

let logger = match log_writer_config {
LogWriterConfig::File { log_file_path, log_level } => {
let fp = DEFAULT_LOG_FILE_PATH
.replace(DEFAULT_STORAGE_DIR_PATH, &node_conf.storage_dir_path);
let log_file_path =
if is_default { &fp } else { log_file_path.as_ref().map(|p| p).unwrap_or(&fp) };

let log_level = log_level.unwrap_or(DEFAULT_LOG_LEVEL);
Some(LogWriterConfig::File { log_file_path, log_level }) => {
let log_file_path = log_file_path
.clone()
.unwrap_or_else(|| format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME));
let log_level = log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL);

@arik-soarik-soJan 30, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how much we gain from using an or_else closure for a constant instead of or here.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, true


Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
LogWriterConfig::Log(log_level) => Logger::new_log_facade(*log_level),
Some(LogWriterConfig::Log(log_level)) => Logger::new_log_facade(*log_level),

LogWriterConfig::Custom(custom_log_writer) => {
Some(LogWriterConfig::Custom(custom_log_writer)) => {
Logger::new_custom_writer(Arc::clone(&custom_log_writer))
},
None => {
// Default to use `FileWriter`
let log_file_path = format!("{}/{}", config.storage_dir_path, DEFAULT_LOG_FILENAME);
let log_level = DEFAULT_LOG_LEVEL;
Logger::new_fs_writer(log_file_path, log_level)
.map_err(|_| BuildError::LoggerSetupFailed)?
},
};

Ok(Arc::new(logger))
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,8 +32,8 @@ const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS: u64 = 25_000;
/// The default log level.
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Debug;

/// The default log file path.
pub const DEFAULT_LOG_FILE_PATH: &'static str = "/tmp/ldk_node/ldk_node.log";
/// The default log file name.
pub const DEFAULT_LOG_FILENAME: &'static str = "ldk_node.log";

/// The default storage directory.
pub const DEFAULT_STORAGE_DIR_PATH: &str = "/tmp/ldk_node";
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -144,7 +144,6 @@ use types::{
pub use types::{ChannelDetails, CustomTlvRecord, PeerDetails, UserChannelId};

use logger::{log_error, log_info, log_trace, LdkLogger, Logger};
pub use logger::{LogLevel, LogRecord, LogWriter};

use lightning::chain::BestBlock;
use lightning::events::bump_transaction::Wallet as LdkWallet;
Expand Down
12 changes: 6 additions & 6 deletions src/logger.rs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how cargo fmt didn't catch that?

@tnulltnullJan 30, 2025

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t touch macros.

Original file line numberDiff line numberDiff line change
Expand Up@@ -143,10 +143,10 @@ impl LogWriter for Writer {
($log_level:expr, $($args:tt)*) => {
match $log_level {
LogLevel::Gossip | LogLevel::Trace => trace!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
LogLevel::Debug => debug!($($args)*),
LogLevel::Info => info!($($args)*),
LogLevel::Warn => warn!($($args)*),
LogLevel::Error => error!($($args)*),
}
};
}
Expand DownExpand Up@@ -174,7 +174,7 @@ pub(crate) struct Logger {
impl Logger {
/// Creates a new logger with a filesystem writer. The parameters to this function
/// are the path to the log file, and the log level.
pub fn new_fs_writer(file_path: &str, level: LogLevel) -> Result<Self, ()> {
pub fn new_fs_writer(file_path: String, level: LogLevel) -> Result<Self, ()> {
if let Some(parent_dir) = Path::new(&file_path).parent() {
fs::create_dir_all(parent_dir)
.map_err(|e| eprintln!("ERROR: Failed to create log parent directory: {}", e))?;
Expand All@@ -187,7 +187,7 @@ impl Logger {
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
}

Ok(Self { writer: Writer::FileWriter { file_path: file_path.to_string(), level } })
Ok(Self { writer: Writer::FileWriter { file_path, level } })
}

pub fn new_log_facade(level: LogLevel) -> Self {
Expand Down
1 change: 1 addition & 0 deletions src/uniffi_types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ pub use crate::config::{
default_config, AnchorChannelsConfig, EsploraSyncConfig, MaxDustHTLCExposure,
};
pub use crate::graph::{ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo};
pub use crate::logger::{LogLevel, LogRecord, LogWriter};
pub use crate::payment::store::{
ConfirmationStatus, LSPFeeLimits, PaymentDirection, PaymentKind, PaymentStatus,
};
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

use persist::KVStoreWalletPersister;

use crate::logger::{log_debug, log_error, log_info, log_trace, Logger, LdkLogger};
use crate::logger::{log_debug, log_error, log_info, log_trace, LdkLogger, Logger};

use crate::fee_estimator::{ConfirmationTarget, FeeEstimator};
use crate::payment::store::{ConfirmationStatus, PaymentStore};
Expand Down