mirror of
https://github.com/alacritty/alacritty.git
synced 2025-04-14 17:53:03 -04:00
Log dependency warnings/errors at trace level
Fixes #5387.
This commit is contained in:
parent
fd0fe967a3
commit
d5c66ceeac
1 changed files with 11 additions and 3 deletions
|
@ -13,7 +13,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use glutin::event_loop::EventLoopProxy;
|
||||
use log::{self, Level};
|
||||
use log::{self, Level, LevelFilter};
|
||||
|
||||
use crate::cli::Options;
|
||||
use crate::event::Event;
|
||||
|
@ -102,8 +102,8 @@ impl log::Log for Logger {
|
|||
let index = record.target().find(':').unwrap_or_else(|| record.target().len());
|
||||
let target = &record.target()[..index];
|
||||
|
||||
// Only log our own crates.
|
||||
if !self.enabled(record.metadata()) || !ALLOWED_TARGETS.contains(&target) {
|
||||
// Only log our own crates, except when logging at Level::Trace.
|
||||
if !self.enabled(record.metadata()) || !is_allowed_target(record.level(), target) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -149,6 +149,14 @@ fn create_log_message(record: &log::Record<'_>, target: &str) -> String {
|
|||
message
|
||||
}
|
||||
|
||||
/// Check if log messages from a crate should be logged.
|
||||
fn is_allowed_target(level: Level, target: &str) -> bool {
|
||||
match (level, log::max_level()) {
|
||||
(Level::Error, LevelFilter::Trace) | (Level::Warn, LevelFilter::Trace) => true,
|
||||
_ => ALLOWED_TARGETS.contains(&target),
|
||||
}
|
||||
}
|
||||
|
||||
struct OnDemandLogFile {
|
||||
file: Option<LineWriter<File>>,
|
||||
created: Arc<AtomicBool>,
|
||||
|
|
Loading…
Add table
Reference in a new issue