Logger should respect configuration

This commit is contained in:
Matthias Beyer 2015-10-26 23:59:24 +01:00
parent 754ad0c6cb
commit 497cdde581
2 changed files with 5 additions and 4 deletions

View file

@ -20,7 +20,7 @@ fn main() {
let mut config = Config::new(app);
let configuration = Configuration::new(&config);
let logger = ImagLogger::init(&config);
let logger = ImagLogger::init(&configuration, &config);
let rt = Runtime::new(config);
info!("Hello, world!");

View file

@ -1,6 +1,7 @@
extern crate log;
pub use cli::Config;
pub use configuration::Configuration as Cfg;
use std::io::stderr;
use std::io::Write;
@ -22,10 +23,10 @@ impl ImagLogger {
ImagLogger::init_logger(LogLevelFilter::Error)
}
pub fn init(config: &Config) -> Result<(), SetLoggerError> {
if config.is_debugging() {
pub fn init(cfg: &Cfg, config: &Config) -> Result<(), SetLoggerError> {
if config.is_debugging() || cfg.is_debugging() {
ImagLogger::init_logger(LogLevelFilter::Debug)
} else if config.is_verbose() {
} else if config.is_verbose() || cfg.is_debugging() {
ImagLogger::init_logger(LogLevelFilter::Info)
} else {
ImagLogger::init_logger(LogLevelFilter::Error)