diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2023-05-04 23:59:55 +0300 |
---|---|---|
committer | Kirill Chibisov <contact@kchibisov.com> | 2023-05-07 00:13:05 +0300 |
commit | ddb9c4a7e421a7039c0ae4cc1195660097ba1ba1 (patch) | |
tree | 6fdd653e322fa6e5420f50688e1aae53b2a340b1 | |
parent | 03e2a5b8e98d7608ee12aaf999e3f65038cffd0d (diff) | |
download | alacritty-ddb9c4a7e421a7039c0ae4cc1195660097ba1ba1.tar.gz alacritty-ddb9c4a7e421a7039c0ae4cc1195660097ba1ba1.zip |
Add `ALACRITTY_EXTRA_LOG_TARGETS` env variable
This should help with troubleshooting the dependency crates like winit.
-rw-r--r-- | alacritty/src/logging.rs | 14 |
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), } } |