1
1
#if NETFRAMEWORK || NETCOREAPP
2
2
3
3
using System ;
4
+ using System . ComponentModel ;
4
5
5
6
namespace Xunit
6
7
{
7
8
/// <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"/>.
10
10
/// </summary>
11
11
public class ConsoleRunnerLogger : IRunnerLogger
12
12
{
13
13
readonly object lockObject ;
14
14
readonly bool useColors ;
15
15
16
+ /// <s
6D4E
ummary/>
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
+
16
26
/// <summary>
17
27
/// Initializes a new instance of the <see cref="ConsoleRunnerLogger"/> class.
18
28
/// </summary>
19
29
/// <param name="useColors">A flag to indicate whether colors should be used when
20
30
/// 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 ( ) ) { }
22
34
23
35
/// <summary>
24
36
/// Initializes a new instance of the <see cref="ConsoleRunnerLogger"/> class.
25
37
/// </summary>
26
38
/// <param name="useColors">A flag to indicate whether colors should be used when
27
39
/// logging messages.</param>
40
+ /// <param name="useAnsiColor">A flag to indicate whether ANSI colors should be
41
+ /// forced on Windows.</param>
28
42
/// <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 )
30
44
{
31
45
this . useColors = useColors ;
32
46
this . lockObject = lockObject ;
47
+
48
+ if ( useAnsiColor )
49
+ ConsoleHelper . UseAnsiColor ( ) ;
33
50
}
34
51
35
52
/// <inheritdoc/>
@@ -40,7 +57,7 @@ public void LogError(StackFrameInfo stackFrame, string message)
40
57
{
41
58
lock ( LockObject )
42
59
using ( SetColor ( ConsoleColor . Red ) )
43
- Console . Error . WriteLine ( message ) ;
60
+ Console . WriteLine ( message ) ;
44
61
}
45
62
46
63
/// <inheritdoc/>
0 commit comments