Move logger initialization to earliest possible point

This commit is contained in:
Matthias Beyer 2016-03-25 19:42:10 +01:00
parent f8c9234a7a
commit d6aa42bd60
6 changed files with 9 additions and 13 deletions

View file

@ -49,8 +49,6 @@ fn main() {
}
};
rt.init_logger();
debug!("Hello. Logging was just enabled");
debug!("I already set up the Runtime object and build the commandline interface parser.");
debug!("Lets get rollin' ...");

View file

@ -40,8 +40,6 @@ fn main() {
}
};
rt.init_logger();
debug!("Hello. Logging was just enabled");
debug!("I already set up the Runtime object and build the commandline interface parser.");
debug!("Lets get rollin' ...");

View file

@ -41,8 +41,6 @@ fn main() {
}
};
rt.init_logger();
debug!("Hello. Logging was just enabled");
debug!("I already set up the Runtime object and build the commandline interface parser.");
debug!("Lets get rollin' ...");

View file

@ -37,8 +37,6 @@ fn main() {
}
};
rt.init_logger();
debug!("Hello. Logging was just enabled");
debug!("I already set up the Runtime object and build the commandline interface parser.");
debug!("Lets get rollin' ...");

View file

@ -45,8 +45,6 @@ fn main() {
}
};
rt.init_logger();
debug!("Hello. Logging was just enabled");
debug!("I already set up the Runtime object and build the commandline interface parser.");
debug!("Lets get rollin' ...");

View file

@ -39,6 +39,12 @@ impl<'a> Runtime<'a> {
use configuration::error::ConfigErrorKind;
let matches = cli_spec.get_matches();
let is_debugging = matches.is_present("debugging");
let is_verbose = matches.is_present("verbosity");
Runtime::init_logger(is_debugging, is_verbose);
let rtp : PathBuf = matches.value_of("runtimepath")
.map(PathBuf::from)
.unwrap_or_else(|| {
@ -153,10 +159,10 @@ impl<'a> Runtime<'a> {
/**
* Initialize the internal logger
*/
pub fn init_logger(&self) {
let lvl = if self.is_debugging() {
fn init_logger(is_debugging: bool, is_verbose: bool) {
let lvl = if is_debugging {
LogLevelFilter::Debug
} else if self.is_verbose() {
} else if is_verbose {
LogLevelFilter::Info
} else {
LogLevelFilter::Error