imag/src/runtime.rs

43 lines
787 B
Rust
Raw Normal View History

2015-10-18 18:52:52 +00:00
use cli::Config;
use std::io::stderr;
use std::io::Write;
pub struct Runtime {
config : Config,
}
impl Runtime {
pub fn new(config : Config) -> Runtime {
Runtime {
config: config,
}
}
2015-10-18 19:15:05 +00:00
pub fn debug(&self, string : &String) {
2015-10-18 18:52:52 +00:00
if self.config.is_debugging() {
println!("{}", string);
}
}
2015-10-18 19:15:05 +00:00
pub fn print(&self, string : &String) {
2015-10-18 18:52:52 +00:00
if self.config.is_verbose() || self.config.is_debugging() {
println!("{}", string);
}
}
2015-10-18 19:15:05 +00:00
pub fn trace(string : &String) {
2015-10-18 18:52:52 +00:00
// writeln!(&mut stderr, "{}", string);
}
pub fn is_verbose(&self) -> bool {
self.config.is_verbose()
}
pub fn is_debugging(&self) -> bool {
self.config.is_debugging()
}
}