Logger should respect configuration
This commit is contained in:
parent
754ad0c6cb
commit
497cdde581
2 changed files with 5 additions and 4 deletions
|
@ -20,7 +20,7 @@ fn main() {
|
||||||
let mut config = Config::new(app);
|
let mut config = Config::new(app);
|
||||||
let configuration = Configuration::new(&config);
|
let configuration = Configuration::new(&config);
|
||||||
|
|
||||||
let logger = ImagLogger::init(&config);
|
let logger = ImagLogger::init(&configuration, &config);
|
||||||
let rt = Runtime::new(config);
|
let rt = Runtime::new(config);
|
||||||
|
|
||||||
info!("Hello, world!");
|
info!("Hello, world!");
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
pub use cli::Config;
|
pub use cli::Config;
|
||||||
|
pub use configuration::Configuration as Cfg;
|
||||||
|
|
||||||
use std::io::stderr;
|
use std::io::stderr;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -22,10 +23,10 @@ impl ImagLogger {
|
||||||
ImagLogger::init_logger(LogLevelFilter::Error)
|
ImagLogger::init_logger(LogLevelFilter::Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(config: &Config) -> Result<(), SetLoggerError> {
|
pub fn init(cfg: &Cfg, config: &Config) -> Result<(), SetLoggerError> {
|
||||||
if config.is_debugging() {
|
if config.is_debugging() || cfg.is_debugging() {
|
||||||
ImagLogger::init_logger(LogLevelFilter::Debug)
|
ImagLogger::init_logger(LogLevelFilter::Debug)
|
||||||
} else if config.is_verbose() {
|
} else if config.is_verbose() || cfg.is_debugging() {
|
||||||
ImagLogger::init_logger(LogLevelFilter::Info)
|
ImagLogger::init_logger(LogLevelFilter::Info)
|
||||||
} else {
|
} else {
|
||||||
ImagLogger::init_logger(LogLevelFilter::Error)
|
ImagLogger::init_logger(LogLevelFilter::Error)
|
||||||
|
|
Loading…
Reference in a new issue