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 8580311 commit e21c3c3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 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
10 changes: 5 additions & 5 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,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 Expand Up @@ -305,8 +305,8 @@ impl LndNode {
.to_string();

let connect_params = bitcoind_connect_params.get_cookie_values().unwrap();
let log_dir_path_buf = lnd_data_dir.join(format!("lnd-logs"));
let log_dir = log_dir_path_buf.as_path();
let log_file_path_buf = lnd_data_dir.join(format!("lnd-logs"));
let log_file = log_file_path_buf.as_path();
let data_dir = lnd_dir.join("data").to_str().unwrap().to_string();
let cert_path = lnd_dir.to_str().unwrap().to_string() + "/tls.cert";
let key_path = lnd_dir.to_str().unwrap().to_string() + "/tls.key";
Expand All @@ -329,7 +329,7 @@ impl LndNode {
format!("--datadir={}", data_dir),
format!("--tlscertpath={}", cert_path),
format!("--tlskeypath={}", key_path),
format!("--logdir={}", log_dir.display()),
format!("--logfile={}", log_file.display()),
format!("--debuglevel=info,PEER=info"),
format!("--bitcoind.rpcuser={}", connect_params.0.unwrap()),
format!("--bitcoind.rpcpass={}", connect_params.1.unwrap()),
Expand Down
8 changes: 4 additions & 4 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,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 @@ -256,8 +256,8 @@ async fn test_lndk_send_invoice_request() {
skip_version_check: false,
};

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 e21c3c3

Please sign in to comment.