@@ -276,17 +276,25 @@ impl Log for SimpleLogger {
276276
277277 fn log ( & self , record : & Record ) {
278278 if self . enabled ( record. metadata ( ) ) {
279- let mut level_string = record. level ( ) . to_string ( ) ;
280-
281- #[ cfg( feature = "colored" ) ]
282- if self . colors {
283- match record. level ( ) {
284- Level :: Error => level_string = level_string. red ( ) . to_string ( ) ,
285- Level :: Warn => level_string = level_string. yellow ( ) . to_string ( ) ,
286- Level :: Info => level_string = level_string. cyan ( ) . to_string ( ) ,
287- Level :: Debug => level_string = level_string. purple ( ) . to_string ( ) ,
288- Level :: Trace => level_string = level_string. normal ( ) . to_string ( ) ,
289- } ;
279+ let level_string = {
280+ #[ cfg( feature = "colored" ) ]
281+ {
282+ if self . colors {
283+ match record. level ( ) {
284+ Level :: Error => record. level ( ) . to_string ( ) . red ( ) . to_string ( ) ,
285+ Level :: Warn => record. level ( ) . to_string ( ) . yellow ( ) . to_string ( ) ,
286+ Level :: Info => record. level ( ) . to_string ( ) . cyan ( ) . to_string ( ) ,
287+ Level :: Debug => record. level ( ) . to_string ( ) . purple ( ) . to_string ( ) ,
288+ Level :: Trace => record. level ( ) . to_string ( ) . normal ( ) . to_string ( ) ,
289+ }
290+ } else {
291+ record. level ( ) . to_string ( )
292+ }
293+ }
294+ #[ cfg( not( feature = "colored" ) ) ]
295+ {
296+ record. level ( ) . to_string ( )
297+ }
290298 } ;
291299
292300 let target = if !record. target ( ) . is_empty ( ) {
0 commit comments