diff options
Diffstat (limited to 'src/liblog')
| -rw-r--r-- | src/liblog/directive.rs | 2 | ||||
| -rw-r--r-- | src/liblog/lib.rs | 18 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/liblog/directive.rs b/src/liblog/directive.rs index 8134503019c..d741019aa7b 100644 --- a/src/liblog/directive.rs +++ b/src/liblog/directive.rs @@ -84,7 +84,7 @@ pub fn parse_logging_spec(spec: &str) -> (Vec<LogDirective>, Option<Regex>) { match Regex::new(filter) { Ok(re) => Some(re), Err(e) => { - println!("warning: invalid regex filter - {}", e); + println!("warning: invalid regex filter - {:?}", e); None } } diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index dd4291d6b51..332dd5e558e 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -16,12 +16,12 @@ //! #[macro_use] extern crate log; //! //! fn main() { -//! debug!("this is a debug {}", "message"); +//! debug!("this is a debug {:?}", "message"); //! error!("this is printed by default"); //! //! if log_enabled!(log::INFO) { //! let x = 3i * 4i; // expensive computation -//! info!("the answer was: {}", x); +//! info!("the answer was: {:?}", x); //! } //! } //! ``` @@ -239,10 +239,16 @@ pub struct LogLevel(pub u32); impl fmt::Show for LogLevel { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, fmt) + } +} + +impl fmt::String for LogLevel { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let LogLevel(level) = *self; match LOG_LEVEL_NAMES.get(level as uint - 1) { - Some(name) => name.fmt(fmt), - None => level.fmt(fmt) + Some(ref name) => fmt::String::fmt(name, fmt), + None => fmt::String::fmt(&level, fmt) } } } @@ -254,7 +260,7 @@ impl Logger for DefaultLogger { record.level, record.module_path, record.args) { - Err(e) => panic!("failed to log: {}", e), + Err(e) => panic!("failed to log: {:?}", e), Ok(()) => {} } } @@ -264,7 +270,7 @@ impl Drop for DefaultLogger { fn drop(&mut self) { // FIXME(#12628): is panicking the right thing to do? match self.handle.flush() { - Err(e) => panic!("failed to flush a logger: {}", e), + Err(e) => panic!("failed to flush a logger: {:?}", e), Ok(()) => {} } } |
