11#if NETFRAMEWORK || NETCOREAPP
22
33using System ;
4+ using System . ComponentModel ;
45
56namespace Xunit
67{
78 /// <summary>
8- /// An implementation of <see cref="IRunnerLogger"/> which logs messages
9- /// to <see cref="Console"/> and <see cref="Console.Error"/>.
9+ /// An implementation of <see cref="IRunnerLogger"/> which logs messages to <see cref="Console"/>.
1010 /// </summary>
1111 public class ConsoleRunnerLogger : IRunnerLogger
1212 {
1313 readonly object lockObject ;
1414 readonly bool useColors ;
1515
16+ /// <summary/>
17+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
18+ [ Obsolete ( "Please use the new overload with the useAnsiColor flag" ) ]
19+ public ConsoleRunnerLogger ( bool useColors ) : this ( useColors , useAnsiColor : false , new object ( ) ) { }
20+
21+ /// <summary/>
22+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
23+ [ Obsolete ( "Please use the new overload with the useAnsiColor flag" ) ]
24+ public ConsoleRunnerLogger ( bool useColors , object lockObject ) : this ( useColors , useAnsiColor : false , lockObject ) { }
25+
1626 /// <summary>
1727 /// Initializes a new instance of the <see cref="ConsoleRunnerLogger"/> class.
1828 /// </summary>
1929 /// <param name="useColors">A flag to indicate whether colors should be used when
2030 /// logging messages.</param>
21- public ConsoleRunnerLogger ( bool useColors ) : this ( useColors , new object ( ) ) { }
31+ /// <param name="useAnsiColor">A flag to indicate whether ANSI colors should be
32+ /// forced on Windows.</param>
33+ public ConsoleRunnerLogger ( bool useColors , bool useAnsiColor ) : this ( useColors , useAnsiColor , new object ( ) ) { }
2234
2335 /// <summary>
2436 /// Initializes a new instance of the <see cref="ConsoleRunnerLogger"/> class.
2537 /// </summary>
2638 /// <param name="useColors">A flag to indicate whether colors should be used when
2739 /// logging messages.</param>
40+ /// <param name="useAnsiColor">A flag to indicate whether ANSI colors should be
41+ /// forced on Windows.</param>
2842 /// <param name="lockObject">The lock object used to prevent console clashes.</param>
29- public ConsoleRunnerLogger ( bool useColors , object lockObject )
43+ public ConsoleRunnerLogger ( bool useColors , bool useAnsiColor , object lockObject )
3044 {
3145 this . useColors = useColors ;
3246 this . lockObject = lockObject ;
47+
48+ if ( useAnsiColor )
49+ ConsoleHelper . UseAnsiColor ( ) ;
3350 }
3451
3552 /// <inheritdoc/>
@@ -40,7 +57,7 @@ public void LogError(StackFrameInfo stackFrame, string message)
4057 {
4158 lock ( LockObject )
4259 using ( SetColor ( ConsoleColor . Red ) )
43- Console . Error . WriteLine ( message ) ;
60+ Console . WriteLine ( message ) ;
4461 }
4562
4663 /// <inheritdoc/>
0 commit comments