aboutsummaryrefslogtreecommitdiff
path: root/src/logging.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/logging.rs')
-rw-r--r--src/logging.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/logging.rs b/src/logging.rs
index 6b7a7968..4584b5f6 100644
--- a/src/logging.rs
+++ b/src/logging.rs
@@ -36,7 +36,6 @@ impl<T: Send + io::Write> Logger<T> {
}
}
-
impl<T: Send + io::Write> log::Log for Logger<T> {
fn enabled(&self, metadata: &log::LogMetadata) -> bool {
metadata.level() <= self.level
@@ -52,8 +51,14 @@ impl<T: Send + io::Write> log::Log for Logger<T> {
}
pub fn initialize(options: &cli::Options) -> Result<(), log::SetLoggerError> {
- log::set_logger(|max_log_level| {
- max_log_level.set(options.log_level);
- Box::new(Logger::new(io::stdout(), options.log_level))
- })
+ // Use env_logger if RUST_LOG environment variable is defined. Otherwise,
+ // use the alacritty-only logger.
+ if ::std::env::var("RUST_LOG").is_ok() {
+ ::env_logger::init()
+ } else {
+ log::set_logger(|max_log_level| {
+ max_log_level.set(options.log_level);
+ Box::new(Logger::new(io::stdout(), options.log_level))
+ })
+ }
}