Skip to content

Commit 86e4ac9

Browse files
committed
filter: Don't print to stdout the warnings due to an invalid spec.
This makes programs that rely on the output of other programs not work properly in these cases. stderr is more appropriate for such things. Indeed, if you `export RUST_LOG="xxx=xxx"` before building this crate for the first time, the build fails :) See rust-lang/rust-bindgen#1502.
1 parent acc1b2c commit 86e4ac9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/filter/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ fn parse_spec(spec: &str) -> (Vec<Directive>, Option<inner::Filter>) {
306306
let mods = parts.next();
307307
let filter = parts.next();
308308
if parts.next().is_some() {
309-
println!("warning: invalid logging spec '{}', \
310-
ignoring it (too many '/'s)", spec);
309+
eprintln!("warning: invalid logging spec '{}', \
310+
ignoring it (too many '/'s)", spec);
311311
return (dirs, None);
312312
}
313313
mods.map(|m| { for s in m.split(',') {
@@ -327,15 +327,15 @@ fn parse_spec(spec: &str) -> (Vec<Directive>, Option<inner::Filter>) {
327327
match part1.parse() {
328328
Ok(num) => (num, Some(part0)),
329329
_ => {
330-
println!("warning: invalid logging spec '{}', \
331-
ignoring it", part1);
330+
eprintln!("warning: invalid logging spec '{}', \
331+
ignoring it", part1);
332332
continue
333333
}
334334
}
335335
},
336336
_ => {
337-
println!("warning: invalid logging spec '{}', \
338-
ignoring it", s);
337+
eprintln!("warning: invalid logging spec '{}', \
338+
ignoring it", s);
339339
continue
340340
}
341341
};
@@ -349,7 +349,7 @@ fn parse_spec(spec: &str) -> (Vec<Directive>, Option<inner::Filter>) {
349349
match inner::Filter::new(filter) {
350350
Ok(re) => Some(re),
351351
Err(e) => {
352-
println!("warning: invalid regex filter - {}", e);
352+
eprintln!("warning: invalid regex filter - {}", e);
353353
None
354354
}
355355
}

0 commit comments

Comments
 (0)