Pass configuration from cfg file to Runtime as well

This commit is contained in:
Matthias Beyer 2015-10-27 00:01:11 +01:00
parent 497cdde581
commit 904d3fa8c0
2 changed files with 6 additions and 4 deletions

View file

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

View file

@ -59,22 +59,24 @@ impl log::Log for ImagLogger {
pub struct Runtime<'a> {
pub config : Config<'a>,
pub configuration : Cfg,
}
impl<'a> Runtime<'a> {
pub fn new(config : Config<'a>) -> Runtime<'a> {
pub fn new(cfg: Cfg, config : Config<'a>) -> Runtime<'a> {
Runtime {
config: config,
configuration: cfg,
}
}
pub fn is_verbose(&self) -> bool {
self.config.is_verbose()
self.config.is_verbose() || self.configuration.is_verbose()
}
pub fn is_debugging(&self) -> bool {
self.config.is_debugging()
self.config.is_debugging() || self.configuration.is_verbose()
}
}