-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(log): drop noisy third-party debug/trace logs #9248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c5bab04
ce9d0ab
2ae3dd0
bce2a33
cdb055f
eb86ae2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,15 +18,52 @@ struct Logger { | |||||||||||||||||||||
| log_file: Option<Mutex<File>>, | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /// Third-party crate targets that emit very noisy debug logs (often per HTTP/2 | ||||||||||||||||||||||
| /// frame, per socket read, etc.) and would otherwise overwhelm `-v` output. | ||||||||||||||||||||||
| /// These are suppressed at Debug level unless `MISE_LOG_VERBOSE_DEPS=1` is set. | ||||||||||||||||||||||
| /// Trace level always lets them through. | ||||||||||||||||||||||
| const NOISY_DEP_TARGETS: &[&str] = &[ | ||||||||||||||||||||||
| "h2", | ||||||||||||||||||||||
| "hyper", | ||||||||||||||||||||||
| "hyper_util", | ||||||||||||||||||||||
| "mio", | ||||||||||||||||||||||
| "reqwest", | ||||||||||||||||||||||
| "rustls", | ||||||||||||||||||||||
| "tokio_util", | ||||||||||||||||||||||
| "tower", | ||||||||||||||||||||||
| "want", | ||||||||||||||||||||||
| ]; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| fn is_noisy_dep_target(target: &str) -> bool { | ||||||||||||||||||||||
| NOISY_DEP_TARGETS | ||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||
| .any(|t| target == *t || target.starts_with(&format!("{t}::"))) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+43
to
+50
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current implementation of You can avoid these allocations by using
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| impl log::Log for Logger { | ||||||||||||||||||||||
| fn enabled(&self, metadata: &Metadata) -> bool { | ||||||||||||||||||||||
| metadata.level() <= *self.level.lock().unwrap() | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| fn log(&self, record: &Record) { | ||||||||||||||||||||||
| let term_level = *self.term_level.lock().unwrap(); | ||||||||||||||||||||||
| let will_log_file = record.level() <= self.file_level && self.log_file.is_some(); | ||||||||||||||||||||||
| let will_log_term = record.level() <= term_level; | ||||||||||||||||||||||
| let mut will_log_file = record.level() <= self.file_level && self.log_file.is_some(); | ||||||||||||||||||||||
| let mut will_log_term = record.level() <= term_level; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Suppress Debug-level spam from noisy third-party crates (e.g. h2 | ||||||||||||||||||||||
| // logging every received DATA frame). Trace still passes through, as | ||||||||||||||||||||||
| // does any level when MISE_LOG_VERBOSE_DEPS=1. | ||||||||||||||||||||||
| if record.level() == Level::Debug | ||||||||||||||||||||||
| && !*env::MISE_LOG_VERBOSE_DEPS | ||||||||||||||||||||||
| && is_noisy_dep_target(record.target()) | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| if self.file_level < LevelFilter::Trace { | ||||||||||||||||||||||
| will_log_file = false; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| if term_level < LevelFilter::Trace { | ||||||||||||||||||||||
| will_log_term = false; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if !will_log_file && !will_log_term { | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.