17
17
18
18
package org .fusesource .jansi ;
19
19
20
+ import static org .fusesource .jansi .internal .CLibrary .STDERR_FILENO ;
20
21
import static org .fusesource .jansi .internal .CLibrary .STDOUT_FILENO ;
21
22
import static org .fusesource .jansi .internal .CLibrary .isatty ;
22
23
@@ -37,11 +38,15 @@ public class AnsiConsole {
37
38
public static final PrintStream out = new PrintStream (wrapOutputStream (system_out ));
38
39
39
40
public static final PrintStream system_err = System .err ;
40
- public static final PrintStream err = new PrintStream (wrapOutputStream (system_err ));
41
+ public static final PrintStream err = new PrintStream (wrapOutputStream (system_err , STDERR_FILENO ));
41
42
42
43
private static int installed ;
43
44
44
45
public static OutputStream wrapOutputStream (final OutputStream stream ) {
46
+ return wrapOutputStream (stream , STDOUT_FILENO );
47
+ }
48
+
49
+ public static OutputStream wrapOutputStream (final OutputStream stream , int fileno ) {
45
50
46
51
// If the jansi.passthrough property is set, then don't interpret
47
52
// any of the ansi sequences.
@@ -77,7 +82,7 @@ public static OutputStream wrapOutputStream(final OutputStream stream) {
77
82
boolean forceColored = Boolean .getBoolean ("jansi.force" );
78
83
// If we can detect that stdout is not a tty.. then setup
79
84
// to strip the ANSI sequences..
80
- int rc = isatty (STDOUT_FILENO );
85
+ int rc = isatty (fileno );
81
86
if ( !forceColored && rc ==0 ) {
82
87
return new AnsiOutputStream (stream );
83
88
}
0 commit comments