Switch from error! and println! to warn!, and set the default log level to warn on debug builds.

This commit is contained in:
Bobby Holley 2017-02-14 16:48:35 -08:00
parent d7d6979144
commit ae87b8a910
6 changed files with 26 additions and 26 deletions

View file

@ -610,15 +610,11 @@ impl ${style_struct.gecko_struct_name} {
% for longhand in stub_longhands: % for longhand in stub_longhands:
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn set_${longhand.ident}(&mut self, _: longhands::${longhand.ident}::computed_value::T) { pub fn set_${longhand.ident}(&mut self, _: longhands::${longhand.ident}::computed_value::T) {
if cfg!(debug_assertions) { warn!("stylo: Unimplemented property setter: ${longhand.name}");
println!("stylo: Unimplemented property setter: ${longhand.name}");
}
} }
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn copy_${longhand.ident}_from(&mut self, _: &Self) { pub fn copy_${longhand.ident}_from(&mut self, _: &Self) {
if cfg!(debug_assertions) { warn!("stylo: Unimplemented property setter: ${longhand.name}");
println!("stylo: Unimplemented property setter: ${longhand.name}");
}
} }
% if longhand.need_clone: % if longhand.need_clone:
#[allow(non_snake_case)] #[allow(non_snake_case)]
@ -2628,7 +2624,7 @@ clip-path
clip_path.mType = StyleShapeSourceType::None; clip_path.mType = StyleShapeSourceType::None;
match v { match v {
ShapeSource::Url(..) => println!("stylo: clip-path: url() not yet implemented"), ShapeSource::Url(..) => warn!("stylo: clip-path: url() not yet implemented"),
ShapeSource::None => {} // don't change the type ShapeSource::None => {} // don't change the type
ShapeSource::Box(reference) => { ShapeSource::Box(reference) => {
clip_path.mReferenceBox = reference.into(); clip_path.mReferenceBox = reference.into();

View file

@ -119,7 +119,7 @@
% if allow_empty: % if allow_empty:
try!(dest.write_str("none")); try!(dest.write_str("none"));
% else: % else:
error!("Found empty value for property ${name}"); warn!("Found empty value for property ${name}");
% endif % endif
} }
for i in iter { for i in iter {
@ -146,7 +146,7 @@
% if allow_empty: % if allow_empty:
try!(dest.write_str("none")); try!(dest.write_str("none"));
% else: % else:
error!("Found empty value for property ${name}"); warn!("Found empty value for property ${name}");
% endif % endif
} }
for i in iter { for i in iter {

View file

@ -103,7 +103,7 @@ impl From<nsRestyleHint> for RestyleHint {
// FIXME(bholley): Finish aligning the binary representations here and // FIXME(bholley): Finish aligning the binary representations here and
// then .expect() the result of the checked version. // then .expect() the result of the checked version.
if Self::from_bits(raw_bits).is_none() { if Self::from_bits(raw_bits).is_none() {
error!("stylo: dropping unsupported restyle hint bits"); warn!("stylo: dropping unsupported restyle hint bits");
} }
Self::from_bits_truncate(raw_bits) Self::from_bits_truncate(raw_bits)

View file

@ -471,7 +471,7 @@ impl RuleNode {
} }
None => { None => {
if indent != 0 { if indent != 0 {
error!("How has this happened?"); warn!("How has this happened?");
} }
let _ = write!(writer, "(root)"); let _ = write!(writer, "(root)");
} }

View file

@ -101,7 +101,7 @@ impl SpecifiedUrl {
// FIXME(heycam) should ensure we always have a principal, etc., // FIXME(heycam) should ensure we always have a principal, etc.,
// when parsing style attributes and re-parsing due to CSS // when parsing style attributes and re-parsing due to CSS
// Variables. // Variables.
println!("stylo: skipping declaration without ParserContextExtraData"); warn!("stylo: skipping declaration without ParserContextExtraData");
return Err(()) return Err(())
}, },
}; };

View file

@ -6,12 +6,13 @@ use app_units::Au;
use atomic_refcell::AtomicRefMut; use atomic_refcell::AtomicRefMut;
use cssparser::Parser; use cssparser::Parser;
use cssparser::ToCss as ParserToCss; use cssparser::ToCss as ParserToCss;
use env_logger; use env_logger::LogBuilder;
use euclid::Size2D; use euclid::Size2D;
use parking_lot::RwLock; use parking_lot::RwLock;
use selectors::Element; use selectors::Element;
use servo_url::ServoUrl; use servo_url::ServoUrl;
use std::borrow::Cow; use std::borrow::Cow;
use std::env;
use std::fmt::Write; use std::fmt::Write;
use std::mem; use std::mem;
use std::ptr; use std::ptr;
@ -91,10 +92,13 @@ use stylesheet_loader::StylesheetLoader;
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_Initialize() -> () { pub extern "C" fn Servo_Initialize() -> () {
// Enable standard Rust logging. // Initialize logging.
// let mut builder = LogBuilder::new();
// See https://doc.rust-lang.org/log/env_logger/index.html for instructions. let default_level = if cfg!(debug_assertions) { "warn" } else { "error" };
env_logger::init().unwrap(); match env::var("RUST_LOG") {
Ok(v) => builder.parse(&v).init().unwrap(),
_ => builder.parse(default_level).init().unwrap(),
};
// Pretend that we're a Servo Layout thread, to make some assertions happy. // Pretend that we're a Servo Layout thread, to make some assertions happy.
thread_state::initialize(thread_state::LAYOUT); thread_state::initialize(thread_state::LAYOUT);
@ -318,8 +322,8 @@ pub extern "C" fn Servo_AnimationValues_Populate(anim: RawGeckoAnimationValueLis
// we should have gone through both iterators // we should have gone through both iterators
if iter.next().is_some() || geckoiter.next().is_some() { if iter.next().is_some() || geckoiter.next().is_some() {
error!("stylo: Mismatched sizes of Gecko and Servo \ warn!("stylo: Mismatched sizes of Gecko and Servo \
array during animation value construction"); array during animation value construction");
} }
} }
@ -671,7 +675,7 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
// FIXME(bholley): Assert against this. // FIXME(bholley): Assert against this.
if data.get_styles().is_none() { if data.get_styles().is_none() {
error!("Calling Servo_ResolvePseudoStyle on unstyled element"); warn!("Calling Servo_ResolvePseudoStyle on unstyled element");
return if is_probe { return if is_probe {
Strong::null() Strong::null()
} else { } else {
@ -962,7 +966,7 @@ pub extern "C" fn Servo_DeclarationBlock_AddPresValue(declarations: RawServoDecl
let long = match prop { let long = match prop {
Ok(PropertyId::Longhand(long)) => long, Ok(PropertyId::Longhand(long)) => long,
_ => { _ => {
error!("stylo: unknown presentation property with id {:?}", property); warn!("stylo: unknown presentation property with id {:?}", property);
return return
} }
}; };
@ -977,7 +981,7 @@ pub extern "C" fn Servo_DeclarationBlock_AddPresValue(declarations: RawServoDecl
) )
)) ))
} else { } else {
error!("stylo: got unexpected non-integer value for font-size presentation attribute"); warn!("stylo: got unexpected non-integer value for font-size presentation attribute");
return return
} }
} }
@ -990,12 +994,12 @@ pub extern "C" fn Servo_DeclarationBlock_AddPresValue(declarations: RawServoDecl
} }
)) ))
} else { } else {
error!("stylo: got unexpected non-integer value for color presentation attribute"); warn!("stylo: got unexpected non-integer value for color presentation attribute");
return return
} }
} }
_ => { _ => {
error!("stylo: cannot handle longhand {:?} from presentation attribute", long); warn!("stylo: cannot handle longhand {:?} from presentation attribute", long);
return return
} }
}; };
@ -1116,7 +1120,7 @@ pub extern "C" fn Servo_TakeChangeHint(element: RawGeckoElementBorrowed) -> nsCh
data.clear_restyle(); data.clear_restyle();
d d
} else { } else {
error!("Trying to get change hint from unstyled element"); warn!("Trying to get change hint from unstyled element");
GeckoRestyleDamage::empty() GeckoRestyleDamage::empty()
}; };
@ -1134,7 +1138,7 @@ pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
let data = unsafe { element.ensure_data() }.borrow_mut(); let data = unsafe { element.ensure_data() }.borrow_mut();
if !data.has_current_styles() { if !data.has_current_styles() {
error!("Resolving style on unstyled element with lazy computation forbidden."); warn!("Resolving style on unstyled element with lazy computation forbidden.");
let per_doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow(); let per_doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
return per_doc_data.default_computed_values().clone().into_strong(); return per_doc_data.default_computed_values().clone().into_strong();
} }