aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2014-05-26 16:31:20 -0400
committerbors-servo <release+servo@mozilla.com>2014-05-26 16:31:20 -0400
commit58d57c91913c49a0c47bd0ac4cba739e4460a6e4 (patch)
treee022286b38b20851a4f3290d19c1371d29d10f8f
parentf057719bf88eb72daba799d59edce718221610ba (diff)
parent4141b776c279431d70141e32af32d1df184e31e1 (diff)
downloadservo-58d57c91913c49a0c47bd0ac4cba739e4460a6e4.tar.gz
servo-58d57c91913c49a0c47bd0ac4cba739e4460a6e4.zip
auto merge of #2445 : SimonSapin/servo/css-warnings, r=jdm
This is on top of the #2433 Rust upgrade.
-rw-r--r--src/components/style/errors.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/components/style/errors.rs b/src/components/style/errors.rs
index 38f11904d4b..215512c8e42 100644
--- a/src/components/style/errors.rs
+++ b/src/components/style/errors.rs
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
use cssparser::ast::{SyntaxError, SourceLocation};
@@ -21,21 +22,24 @@ impl<T, I: Iterator<Result<T, SyntaxError>>> Iterator<T> for ErrorLoggerIterator
}
-// FIXME: go back to `()` instead of `bool` after upgrading Rust
-// past 898669c4e203ae91e2048fb6c0f8591c867bccc6
-// Using bool is a work-around for https://github.com/mozilla/rust/issues/13322
-local_data_key!(silence_errors: bool)
-
+/// Defaults to a no-op.
+/// Set a `RUST_LOG=style::errors` environment variable
+/// to log CSS parse errors to stderr.
pub fn log_css_error(location: SourceLocation, message: &str) {
- // TODO eventually this will got into a "web console" or something.
- if silence_errors.get().is_none() {
- error!("{:u}:{:u} {:s}", location.line, location.column, message)
+ // Check this first as it’s cheaper than local_data.
+ if log_enabled!(::log::INFO) {
+ if silence_errors.get().is_none() {
+ // TODO eventually this will got into a "web console" or something.
+ info!("{:u}:{:u} {:s}", location.line, location.column, message)
+ }
}
}
+local_data_key!(silence_errors: ())
+
pub fn with_errors_silenced<T>(f: || -> T) -> T {
- silence_errors.replace(Some(true));
+ silence_errors.replace(Some(()));
let result = f();
silence_errors.replace(None);
result