$DEBUG to see output in stderr
This commit is contained in:
@@ -201,21 +201,27 @@ pub fn build_output_stream(cfg: &Stream) -> Box<dyn OutputStream> {
|
||||
pub struct OutputStreamFormatted {
|
||||
format: Option<String>,
|
||||
stream: Box<dyn OutputStream>,
|
||||
debug: bool,
|
||||
}
|
||||
|
||||
pub fn build_formatted_output_stream(cfg: &Stream, stream: Box<dyn OutputStream>) -> Box<dyn OutputStream> {
|
||||
return Box::new(OutputStreamFormatted{
|
||||
format: cfg.format.clone(),
|
||||
debug: cfg.debug,
|
||||
stream: stream,
|
||||
});
|
||||
}
|
||||
|
||||
impl OutputStream for OutputStreamFormatted {
|
||||
fn put(&mut self, v: Vec<char>) {
|
||||
match self.format.as_ref() {
|
||||
Some(x) => self.stream.put(sprintf(x, v)),
|
||||
None => self.stream.put(v),
|
||||
let v2 = match self.format.as_ref() {
|
||||
Some(x) => sprintf(x, v),
|
||||
None => v,
|
||||
};
|
||||
if self.debug {
|
||||
eprintln!("output: {}", v2.iter().collect::<String>());
|
||||
}
|
||||
self.stream.put(v2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user