@@ -348,7 +348,7 @@ impl SimpleLogger {
348
348
/// 'Init' the actual logger and instantiate it,
349
349
/// this method MUST be called in order for the logger to be effective.
350
350
pub fn init ( self ) -> Result < ( ) , SetLoggerError > {
351
- # [ cfg ( all ( windows , feature = "colored" ) ) ]
351
+ // Setup colors if needed. The implementation if feature dependent.
352
352
set_up_color_terminal ( ) ;
353
353
354
354
log:: set_max_level ( self . max_level ( ) ) ;
@@ -481,7 +481,7 @@ impl Log for SimpleLogger {
481
481
fn flush ( & self ) { }
482
482
}
483
483
484
- /// Configure the console to display colours.
484
+ /// Configure the console to display colours - Windows + colored
485
485
///
486
486
/// This is only needed on Windows when using the 'colored' feature.
487
487
#[ cfg( all( windows, feature = "colored" ) ) ]
@@ -513,10 +513,27 @@ pub fn set_up_color_terminal() {
513
513
}
514
514
}
515
515
516
- /// Configure the console to display colours.
516
+ /// Configure the console to display colours - Windows + !colored
517
517
///
518
- /// This method does nothing if not running on Windows with the colored feature.
519
- #[ cfg( not( all( windows, feature = "colored" ) ) ) ]
518
+ /// This method does nothing if running on Windows with the colored feature disabled.
519
+ #[ cfg( all( windows, not( feature = "colored" ) ) ) ]
520
+ pub fn set_up_color_terminal ( ) { }
521
+
522
+ /// Configure the console to display colours - !Windows + stderr + colors
523
+ ///
524
+ /// The colored crate will disable colors when stdout is not a terminal. This method overrides this
525
+ /// behaviour to check the status of stderr instead.
526
+ #[ cfg( all( not( windows) , feature = "stderr" , feature = "colored" ) ) ]
527
+ pub fn set_up_color_terminal ( ) {
528
+ use std:: io:: { stderr, IsTerminal } ;
529
+ colored:: control:: set_override ( stderr ( ) . is_terminal ( ) ) ;
530
+ }
531
+
532
+ /// Configure the console to display colours - !Windows + !stderr
533
+ ///
534
+ /// This method does nothing if not running on Windows with the colored feature and outputting on
535
+ /// stdout.
536
+ #[ cfg( all( not( windows) , not( feature = "stderr" ) ) ) ]
520
537
pub fn set_up_color_terminal ( ) { }
521
538
522
539
/// Initialise the logger with its default configuration.
0 commit comments