From c68f33babec548eac17cd2d26edb9521fbda47ad Mon Sep 17 00:00:00 2001 From: Erocs Date: Mon, 29 Apr 2019 16:56:38 +0000 Subject: [PATCH] Add VOXYGEN_LOG env variable to allow detailed terminal logging. Former-commit-id: 01c29a65311dbd6a4739be5aca9865d4ac0872d9 --- voxygen/src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index 72e601c968..af3a263b8a 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -18,7 +18,7 @@ pub mod singleplayer; // Reexports pub use crate::error::Error; -use std::{mem, thread, panic, fs::File}; +use std::{mem, thread, panic, fs::File, str::FromStr}; use log; use simplelog::{CombinedLogger, TermLogger, WriteLogger, Config}; use crate::{ @@ -87,8 +87,12 @@ fn main() { let window = Window::new(&settings).expect("Failed to create window"); // Init logging + let term_log_level = std::env::var_os("VOXYGEN_LOG") + .and_then(|env| env.to_str().map(|s| s.to_owned())) + .and_then(|s| log::LevelFilter::from_str(&s).ok()) + .unwrap_or(log::LevelFilter::Warn); CombinedLogger::init(vec![ - TermLogger::new(log::LevelFilter::Warn, Config::default()).unwrap(), + TermLogger::new(term_log_level, Config::default()).unwrap(), WriteLogger::new(log::LevelFilter::Info, Config::default(), File::create(&settings.log.file).unwrap()), ]).unwrap();