aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2023-05-04 23:59:55 +0300
committerGitHub <noreply@github.com>2023-05-04 23:59:55 +0300
commit3636383b267308686843e2213a7d90036af96faf (patch)
treed5449c863d4a3d98dab44efed03f1c0185d8b880
parent934d6a2dd7f3a67f046a1a17da54b58de677a81e (diff)
downloadalacritty-3636383b267308686843e2213a7d90036af96faf.tar.gz
alacritty-3636383b267308686843e2213a7d90036af96faf.zip
Add `ALACRITTY_EXTRA_LOG_TARGETS` env variable
This should help with troubleshooting the dependency crates like winit.
-rw-r--r--alacritty/src/logging.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/alacritty/src/logging.rs b/alacritty/src/logging.rs
index 846ab1c5..fffd9c02 100644
--- a/alacritty/src/logging.rs
+++ b/alacritty/src/logging.rs
@@ -13,6 +13,7 @@ use std::time::Instant;
use std::{env, process};
use log::{self, Level, LevelFilter};
+use once_cell::sync::Lazy;
use winit::event_loop::EventLoopProxy;
use alacritty_terminal::config::LOG_TARGET_CONFIG;
@@ -27,6 +28,17 @@ pub const LOG_TARGET_IPC_CONFIG: &str = "alacritty_log_ipc_config";
/// Name for the environment variable containing the log file's path.
const ALACRITTY_LOG_ENV: &str = "ALACRITTY_LOG";
+/// Name for the environment varibale containing extra logging targets.
+///
+/// The targets are semicolon separated.
+const ALACRITTY_EXTRA_LOG_TARGETS_ENV: &str = "ALACRITTY_EXTRA_LOG_TARGETS";
+
+/// User configurable extra log targets to include.
+static EXTRA_LOG_TARGETS: Lazy<Vec<String>> = Lazy::new(|| {
+ env::var(ALACRITTY_EXTRA_LOG_TARGETS_ENV)
+ .map_or(Vec::new(), |targets| targets.split(';').map(ToString::to_string).collect())
+});
+
/// List of targets which will be logged by Alacritty.
const ALLOWED_TARGETS: &[&str] = &[
LOG_TARGET_IPC_CONFIG,
@@ -167,7 +179,7 @@ fn create_log_message(record: &log::Record<'_>, target: &str, start: Instant) ->
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),
+ _ => ALLOWED_TARGETS.contains(&target) || EXTRA_LOG_TARGETS.iter().any(|t| t == target),
}
}