feat: log to file by default and allow custom log file path#969
Open
kanishka0411 wants to merge 1 commit into
Open
feat: log to file by default and allow custom log file path#969kanishka0411 wants to merge 1 commit into
kanishka0411 wants to merge 1 commit into
Conversation
GideonBature
left a comment
There was a problem hiding this comment.
tACK
running 7 tests
test tests::test_resolve_debug_log_file_absolute_path ... ok
test tests::test_resolve_debug_log_file_default ... ok
test tests::test_resolve_debug_log_file_disabled ... ok
test tests::test_resolve_debug_log_file_disabled_overrides_custom ... ok
test tests::test_resolve_debug_log_file_network_specific_datadir ... ok
test tests::test_resolve_debug_log_file_relative_path ... ok
test tests::test_resolve_debug_log_file_relative_subdir ... ok
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00sI ran the tests and they all passed. And the solution LGTM.
Davidson-Souza
requested changes
Apr 21, 2026
| #[arg(long)] | ||
| /// Option for saving log into data_Dir | ||
| #[arg(long, value_name = "FILE")] | ||
| /// Specify location of debug log file |
Member
There was a problem hiding this comment.
I think debug log file is redundant. Just log file is fine
Comment on lines
+192
to
+218
| /// Resolves the debug log file path from the CLI flags. | ||
| /// | ||
| /// File logging is enabled by default (matching Bitcoin Core). The user can: | ||
| /// - Override the path with `--debuglogfile=<path>` | ||
| /// - Disable file logging entirely with `--nodebuglogfile` | ||
| /// | ||
| /// Relative paths are prefixed by the net-specific `data_dir`. | ||
| /// Returns `None` when file logging is disabled, or `Some(absolute_path)` otherwise. | ||
| fn resolve_debug_log_file( | ||
| no_debug_log_file: bool, | ||
| debug_log_file: Option<&str>, | ||
| data_dir: &str, | ||
| ) -> Option<String> { | ||
| if no_debug_log_file { | ||
| return None; | ||
| } | ||
|
|
||
| let raw = debug_log_file.unwrap_or(LOG_FILE); | ||
| let path = PathBuf::from(raw); | ||
| let absolute = if path.is_absolute() { | ||
| path | ||
| } else { | ||
| PathBuf::from(data_dir).join(path) | ||
| }; | ||
| Some(absolute.to_string_lossy().into_owned()) | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
I think this can live inside logger.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description and Notes
Related to #947
This aligns Floresta logging behavior with Bitcoin Core defaults by enabling file logging by default. Previously, file logging required an explicit flag; now logs are written to <data_dir>/debug.log automatically.
New CLI flags:
How to verify the changes you have done?
Contributor Checklist
just pcc(recommended but slower)just lint-features '-- -D warnings' && cargo test --release