@@ -38,7 +38,7 @@ pub fn parse_logging_spec(spec: &str) -> Vec<LogDirective> {
38
38
for s in spec. split ( ',' ) {
39
39
if s. len ( ) == 0 { continue }
40
40
let mut parts = s. split ( '=' ) ;
41
- let ( log_level, name) = match ( parts. next ( ) , parts. next ( ) , parts. next ( ) ) {
41
+ let ( log_level, name) = match ( parts. next ( ) , parts. next ( ) . map ( |s| s . trim ( ) ) , parts. next ( ) ) {
42
42
( Some ( part0) , None , None ) => {
43
43
// if the single argument is a log-level string or number,
44
44
// treat that as a global fallback
@@ -47,6 +47,7 @@ pub fn parse_logging_spec(spec: &str) -> Vec<LogDirective> {
47
47
None => ( :: MAX_LOG_LEVEL , Some ( part0) ) ,
48
48
}
49
49
}
50
+ ( Some ( part0) , Some ( "" ) , None ) => ( :: MAX_LOG_LEVEL , Some ( part0) ) ,
50
51
( Some ( part0) , Some ( part1) , None ) => {
51
52
match parse_log_level ( part1) {
52
53
Some ( num) => ( num, Some ( part0) ) ,
@@ -120,6 +121,16 @@ mod tests {
120
121
assert_eq ! ( dirs[ 0 ] . level, :: WARN ) ;
121
122
}
122
123
124
+ #[ test]
125
+ fn parse_logging_spec_empty_log_level ( ) {
126
+ // test parse_logging_spec with '' as log level
127
+ let dirs = parse_logging_spec ( "crate1::mod1=wrong,crate2=" ) ;
128
+ let dirs = dirs. as_slice ( ) ;
129
+ assert_eq ! ( dirs. len( ) , 1 ) ;
130
+ assert_eq ! ( dirs[ 0 ] . name, Some ( "crate2" . to_string( ) ) ) ;
131
+ assert_eq ! ( dirs[ 0 ] . level, :: MAX_LOG_LEVEL ) ;
132
+ }
133
+
123
134
#[ test]
124
135
fn parse_logging_spec_global ( ) {
125
136
// test parse_logging_spec with no crate
0 commit comments