Optimize CSS error logging: check log level before task-local silencing.

This commit is contained in:
Simon Sapin 2014-05-15 19:43:04 +01:00
parent 6a2a080355
commit 4141b776c2

View file

@ -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};
@ -25,9 +26,12 @@ impl<T, I: Iterator<Result<T, SyntaxError>>> Iterator<T> for ErrorLoggerIterator
/// 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() {
info!("{:u}:{:u} {:s}", location.line, location.column, message)
// Check this first as its 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)
}
}
}