about summary refs log tree commit diff
path: root/src/liblog/lib.rs
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2015-01-24 09:15:42 -0800
committerBrian Anderson <banderson@mozilla.com>2015-01-25 01:20:55 -0800
commit63fcbcf3ce8f0ca391c18b2d61833ae6beb3ac70 (patch)
treec732033c0822f25f2aebcdf193de1b257bac1855 /src/liblog/lib.rs
parentb44ee371b8beea77aa1364460acbba14a8516559 (diff)
parent0430a43d635841db44978bb648e9cf7e7cfa1bba (diff)
downloadrust-63fcbcf3ce8f0ca391c18b2d61833ae6beb3ac70.tar.gz
rust-63fcbcf3ce8f0ca391c18b2d61833ae6beb3ac70.zip
Merge remote-tracking branch 'rust-lang/master'
Conflicts:
	mk/tests.mk
	src/liballoc/arc.rs
	src/liballoc/boxed.rs
	src/liballoc/rc.rs
	src/libcollections/bit.rs
	src/libcollections/btree/map.rs
	src/libcollections/btree/set.rs
	src/libcollections/dlist.rs
	src/libcollections/ring_buf.rs
	src/libcollections/slice.rs
	src/libcollections/str.rs
	src/libcollections/string.rs
	src/libcollections/vec.rs
	src/libcollections/vec_map.rs
	src/libcore/any.rs
	src/libcore/array.rs
	src/libcore/borrow.rs
	src/libcore/error.rs
	src/libcore/fmt/mod.rs
	src/libcore/iter.rs
	src/libcore/marker.rs
	src/libcore/ops.rs
	src/libcore/result.rs
	src/libcore/slice.rs
	src/libcore/str/mod.rs
	src/libregex/lib.rs
	src/libregex/re.rs
	src/librustc/lint/builtin.rs
	src/libstd/collections/hash/map.rs
	src/libstd/collections/hash/set.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/mutex.rs
	src/libstd/sync/poison.rs
	src/libstd/sync/rwlock.rs
	src/libsyntax/feature_gate.rs
	src/libsyntax/test.rs
Diffstat (limited to 'src/liblog/lib.rs')
-rw-r--r--src/liblog/lib.rs39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs
index 6fe789f3e31..05b831a5a59 100644
--- a/src/liblog/lib.rs
+++ b/src/liblog/lib.rs
@@ -123,11 +123,11 @@
 //!
 //! # Filtering results
 //!
-//! A RUST_LOG directive may include a regex filter. The syntax is to append `/`
-//! followed by a regex. Each message is checked against the regex, and is only
-//! logged if it matches. Note that the matching is done after formatting the log
-//! string but before adding any logging meta-data. There is a single filter for all
-//! modules.
+//! A RUST_LOG directive may include a string filter. The syntax is to append
+//! `/` followed by a string. Each message is checked against the string and is
+//! only logged if it contains the string. Note that the matching is done after
+//! formatting the log string but before adding any logging meta-data. There is
+//! a single filter for all modules.
 //!
 //! Some examples:
 //!
@@ -179,20 +179,17 @@
 #![feature(rustc_private)]
 #![feature(std_misc)]
 
-extern crate regex;
-
 use std::cell::RefCell;
 use std::fmt;
 use std::io::LineBufferedWriter;
 use std::io;
 use std::mem;
 use std::os;
+use std::ptr;
 use std::rt;
 use std::slice;
 use std::sync::{Once, ONCE_INIT};
 
-use regex::Regex;
-
 use directive::LOG_LEVEL_NAMES;
 
 #[macro_use]
@@ -215,8 +212,8 @@ static mut LOG_LEVEL: u32 = MAX_LOG_LEVEL;
 static mut DIRECTIVES: *const Vec<directive::LogDirective> =
     0 as *const Vec<directive::LogDirective>;
 
-/// Optional regex filter.
-static mut FILTER: *const Regex = 0 as *const _;
+/// Optional filter.
+static mut FILTER: *const String = 0 as *const _;
 
 /// Debug log level
 pub const DEBUG: u32 = 4;
@@ -246,21 +243,15 @@ struct DefaultLogger {
 }
 
 /// Wraps the log level with fmt implementations.
-#[derive(Copy, PartialEq, PartialOrd)]
+#[derive(Copy, PartialEq, PartialOrd, Show)]
 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 {
+impl fmt::Display 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(ref name) => fmt::String::fmt(name, fmt),
-            None => fmt::String::fmt(&level, fmt)
+            Some(ref name) => fmt::Display::fmt(name, fmt),
+            None => fmt::Display::fmt(&level, fmt)
         }
     }
 }
@@ -300,7 +291,7 @@ pub fn log(level: u32, loc: &'static LogLocation, args: fmt::Arguments) {
     // Test the literal string from args against the current filter, if there
     // is one.
     match unsafe { FILTER.as_ref() } {
-        Some(filter) if !filter.is_match(&args.to_string()[]) => return,
+        Some(filter) if !args.to_string().contains(&filter[]) => return,
         _ => {}
     }
 
@@ -444,10 +435,10 @@ fn init() {
             assert!(!DIRECTIVES.is_null());
             let _directives: Box<Vec<directive::LogDirective>> =
                 mem::transmute(DIRECTIVES);
-            DIRECTIVES = 0 as *const Vec<directive::LogDirective>;
+            DIRECTIVES = ptr::null();
 
             if !FILTER.is_null() {
-                let _filter: Box<Regex> = mem::transmute(FILTER);
+                let _filter: Box<String> = mem::transmute(FILTER);
                 FILTER = 0 as *const _;
             }
         });