7171 html_root_url = "http://doc.rust-lang.org/env_logger/" ) ]
7272#![ cfg_attr( test, deny( warnings) ) ]
7373
74- extern crate regex;
7574#[ macro_use]
7675extern crate slog;
7776extern crate slog_term;
@@ -80,11 +79,18 @@ extern crate slog_scope;
8079extern crate slog_async;
8180extern crate log;
8281
83- use regex:: Regex ;
8482use std:: { env, result, sync} ;
8583use std:: cell:: RefCell ;
8684use slog:: * ;
8785
86+ #[ cfg( feature = "regex" ) ]
87+ #[ path = "regex.rs" ]
88+ mod filter;
89+
90+ #[ cfg( not( feature = "regex" ) ) ]
91+ #[ path = "string.rs" ]
92+ mod filter;
93+
8894thread_local ! {
8995 static TL_BUF : RefCell <String > = RefCell :: new( String :: new( ) )
9096}
@@ -93,7 +99,7 @@ thread_local! {
9399pub struct EnvLogger < T : Drain > {
94100 drain : T ,
95101 directives : Vec < LogDirective > ,
96- filter : Option < Regex > ,
102+ filter : Option < filter :: Filter > ,
97103}
98104
99105/// LogBuilder acts as builder for initializing the EnvLogger.
@@ -102,7 +108,7 @@ pub struct EnvLogger<T : Drain> {
102108pub struct LogBuilder < T : Drain > {
103109 drain : T ,
104110 directives : Vec < LogDirective > ,
105- filter : Option < Regex > ,
111+ filter : Option < filter :: Filter > ,
106112}
107113
108114impl < T : Drain > LogBuilder < T > {
@@ -271,7 +277,7 @@ pub fn init() -> std::result::Result<slog_scope::GlobalLoggerGuard, log::SetLogg
271277
272278/// Parse a logging specification string (e.g: "crate1,crate2::mod3,crate3::x=error/foo")
273279/// and return a vector with log directives.
274- fn parse_logging_spec ( spec : & str ) -> ( Vec < LogDirective > , Option < Regex > ) {
280+ fn parse_logging_spec ( spec : & str ) -> ( Vec < LogDirective > , Option < filter :: Filter > ) {
275281 let mut dirs = Vec :: new ( ) ;
276282
277283 let mut parts = spec. split ( '/' ) ;
@@ -318,7 +324,7 @@ fn parse_logging_spec(spec: &str) -> (Vec<LogDirective>, Option<Regex>) {
318324 } } ) ;
319325
320326 let filter = filter. map_or ( None , |filter| {
321- match Regex :: new ( filter) {
327+ match filter :: Filter :: new ( filter) {
322328 Ok ( re) => Some ( re) ,
323329 Err ( e) => {
324330 println ! ( "warning: invalid regex filter - {}" , e) ;
0 commit comments