feat(log): emit program identity banner + module target on every line (closes #310)#320
Open
0xghost42 wants to merge 1 commit into
Open
feat(log): emit program identity banner + module target on every line (closes #310)#3200xghost42 wants to merge 1 commit into
0xghost42 wants to merge 1 commit into
Conversation
…closes domcyrus#310) Issue domcyrus#310: the existing log file only shows timestamp + level + message, so a user looking at a long-running rustnet log has no direct way to confirm which binary, which version, and which pid produced the entries. Two small changes in `setup_logging`: 1. Switch from `LogConfig::default()` to a `ConfigBuilder` with `set_target_level(LevelFilter::Error)`, which tells simplelog to include the originating `target` (module path) on every log line. So instead of just: 2026-05-25 18:00:00 [INFO] Refreshing connections the user now sees which subsystem emitted the line: 2026-05-25 18:00:00 [INFO] (rustnet_monitor::network::poll) Refreshing connections 2. Emit a one-line startup banner immediately after the writer is wired up: 2026-05-25 18:00:00 [INFO] (rustnet_monitor::main) rustnet-monitor v1.3.0 starting (pid 12345) `pkg_name` and `pkg_version` come from `env!("CARGO_PKG_NAME")` / `env!("CARGO_PKG_VERSION")` so they stay correct when the binary is renamed or symlinked (i.e. not derived from `argv[0]`). `cargo build`, `cargo clippy --all-targets -- -D warnings`, `cargo fmt --check`, and `cargo test --lib` (365 pass) are all clean. No behavior change outside the log file format.
domcyrus
reviewed
May 25, 2026
| // Check privileges BEFORE initializing TUI (so error messages are visible) | ||
| check_privileges_early()?; | ||
|
|
||
| info!("Starting RustNet Monitor"); |
Owner
There was a problem hiding this comment.
I'm curious with this and the one you've added further down we have two starting RustNet log lines, should they be combined.
Owner
|
@0xghost42 Thanks a lot for your PR, Ive added one minor comment which I think we should tackle prior merging this. |
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.
Why
Issue #310: the existing log file only carries timestamp + level + message, so a user looking at a long-running
rustnetlog has no direct way to confirm which binary, which version, and which pid produced the entries.What
Two small changes in
setup_logging:Module target on every line. Switch from
LogConfig::default()to aConfigBuilderwithset_target_level(LevelFilter::Error), which tellssimplelogto include the originatingtarget(module path) on every log line.Before:
After:
Startup banner with program identity. Emit one identifying line immediately after the writer is wired up:
pkg_nameandpkg_versioncome fromenv!("CARGO_PKG_NAME")/env!("CARGO_PKG_VERSION")so they stay correct when the binary is renamed or symlinked (i.e. not derived fromargv[0]). The pid usesstd::process::id().Verification
No behavior change outside the log file format. Open to feedback if you'd prefer the banner phrased differently (e.g. include the BPF filter / interface in the startup line, or include the start timestamp explicitly even though
simplelogalready stamps each line).Closes #310