Skip to content

Commit

Permalink
Renamed log_dir configuration to log_file.
Browse files Browse the repository at this point in the history
This is expected to be passed in as a file, not a directory, so change
the name to reflect that fact.
  • Loading branch information
mhrheaume committed Nov 11, 2024
1 parent 19638ff commit d6c665f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config_spec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type = "String"
doc = "The path to the lndk data directory. By default this is stored in ~/.lndk"

[[param]]
name = "log_dir"
name = "log_file"
type = "String"
doc = "The path to the lndk log file. If not specified, defaults to `<data_dir>/lndk.log`."

Expand Down
4 changes: 1 addition & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ async fn main() -> Result<(), ()> {
let data_dir = create_data_dir(&config.data_dir)
.map_err(|e| println!("Error creating LNDK's data dir {e:?}"))?;

let log_file = config.log_dir.map(PathBuf::from).or(config
// The log_dir configuration is actually a file path, not a directory. So if we are
// falling back to data_dir, append the default log file name to get a file path.
let log_file = config.log_file.map(PathBuf::from).or(config
.data_dir
.map(|data_dir| PathBuf::from(data_dir).join(DEFAULT_LOG_FILE)));

Expand Down
4 changes: 2 additions & 2 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ pub async fn setup_lndk(
let handler = Arc::new(lndk::OfferHandler::default());
let messenger = lndk::LndkOnionMessenger::new();

let log_dir = Some(lndk_dir.join(format!("lndk-logs.txt")));
setup_logger(None, log_dir).unwrap();
let log_file = Some(lndk_dir.join(format!("lndk-logs.txt")));
setup_logger(None, log_file).unwrap();

return (lndk_cfg, handler, messenger, shutdown);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ async fn test_lndk_send_invoice_request() {
}
}

let log_dir = Some(lndk_dir.join(format!("lndk-logs.txt")));
setup_logger(None, log_dir).unwrap();
let log_file = Some(lndk_dir.join(format!("lndk-logs.txt")));
setup_logger(None, log_file).unwrap();

// Make sure lndk successfully sends the invoice_request.
let handler = Arc::new(lndk::OfferHandler::default());
Expand Down Expand Up @@ -260,8 +260,8 @@ async fn test_lndk_send_invoice_request() {
rate_limit_period_secs: 1,
};

let log_dir = Some(lndk_dir.join(format!("lndk-logs.txt")));
setup_logger(None, log_dir).unwrap();
let log_file = Some(lndk_dir.join(format!("lndk-logs.txt")));
setup_logger(None, log_file).unwrap();

let handler = Arc::new(lndk::OfferHandler::default());
let messenger = lndk::LndkOnionMessenger::new();
Expand Down

0 comments on commit d6c665f

Please sign in to comment.