mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
auto merge of #2445 : SimonSapin/servo/css-warnings, r=jdm
This is on top of the #2433 Rust upgrade.
This commit is contained in:
commit
58d57c9191
1 changed files with 13 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue