Print debug messages to stderr instead

This commit is contained in:
Tad Hardesty 2018-03-09 01:08:11 -08:00
parent 9d98df3849
commit f0ed44fe03
2 changed files with 7 additions and 7 deletions

View file

@ -31,7 +31,7 @@ pub mod constants;
impl Context {
/// Run the parsing suite on a given `.dme` file, producing an object tree.
///
/// Errors are automatically pretty-printed to stdout before they are returned.
/// Errors are automatically pretty-printed to stderr before they are returned.
pub fn parse_environment(&mut self, dme: &Path) -> Result<objtree::ObjectTree, DMError> {
let start = self.errors().len();
let result = parser::parse(
@ -42,13 +42,13 @@ impl Context {
);
let errors = self.errors();
let stdout = io::stdout();
let stdout = &mut stdout.lock();
let stderr = io::stderr();
let stderr = &mut stderr.lock();
for err in &errors[start..] {
self.pretty_print_error(stdout, &err).expect("error writing to stdout");
self.pretty_print_error(stderr, &err).expect("error writing to stderr");
}
if let Err(ref err) = result {
self.pretty_print_error(stdout, &err).expect("error writing to stdout");
self.pretty_print_error(stderr, &err).expect("error writing to stderr");
}
result

View file

@ -21,7 +21,7 @@ pub fn parse<I>(context: &Context, iter: I) -> Result<ObjectTree, DMError> where
let procs_total = parser.procs_good + parser.procs_bad;
if procs_total > 0 {
println!("parsed {}/{} proc bodies ({}%)", parser.procs_good, procs_total, (parser.procs_good * 100 / procs_total));
eprintln!("parsed {}/{} proc bodies ({}%)", parser.procs_good, procs_total, (parser.procs_good * 100 / procs_total));
}
Ok(tree)
@ -365,7 +365,7 @@ impl<I> Parser<I> where
// read and calculate the current path
let (absolute, path) = leading!(self.tree_path());
if absolute && parent.parent.is_some() {
println!("WARNING: {:?} inside {:?}", path, parent);
eprintln!("WARNING: {:?} inside {:?}", path, parent);
}
let new_stack = PathStack {
parent: if absolute { None } else { Some(&parent) },