summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Bosnick <sbosnick@sympatico.ca>2021-08-03 21:00:18 -0400
committerGitHub <noreply@github.com>2021-08-04 01:00:18 +0000
commitd5c66ceeacb30a3ba97591bd8ae7eb4d11c7abf5 (patch)
treeb4528e58fcb111a1503f194f3465b03bbf771f78
parentfd0fe967a3750a95ea54012f4d3f862ae0615f21 (diff)
downloadalacritty-d5c66ceeacb30a3ba97591bd8ae7eb4d11c7abf5.tar.gz
alacritty-d5c66ceeacb30a3ba97591bd8ae7eb4d11c7abf5.zip
Log dependency warnings/errors at trace level
Fixes #5387.
-rw-r--r--alacritty/src/logging.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/alacritty/src/logging.rs b/alacritty/src/logging.rs
index cbe2ef99..545905a2 100644
--- a/alacritty/src/logging.rs
+++ b/alacritty/src/logging.rs
@@ -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>,