[
https://issues.apache.org/jira/browse/GROOVY-12784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146020#comment-18146020
]
ASF GitHub Bot commented on GROOVY-12784:
-----------------------------------------
codeconsole opened a new pull request, #3309:
URL: https://github.com/apache/groovy/pull/3309
https://issues.apache.org/jira/browse/GROOVY-12784
`IO` looked for `org.fusesource.jansi.AnsiRenderWriter`, which Groovy has
not shipped since GROOVY-8162, so `ansiSupported` was always `false` and the
shell `Logger` (groovydoc's logger) printed DEBUG, WARN and ERROR uncolored.
`IO` now renders through JLine Jansi's `AnsiConsole`, for the JVM's own
standard output and error only:
- a terminal gets the colors (bold green DEBUG, bold red WARN and ERROR)
- output redirected to a file or a pipe stays plain, since `AnsiConsole`
strips the escape sequences there
- `-Djansi.mode=force` / `strip` still override the detection
- any other stream, or a `System.out` replaced after `AnsiConsole` captured
the original, keeps a plain `PrintWriter`
Jansi stays optional: `IO` checks for `org.jline.jansi.AnsiConsole` before
touching it. Core's tests now run with the `logging` feature, as they already
do with `grapes`, so `IOTest` can cover the redirected and the forced cases in
a forked JVM.
Opening the console builds JLine's system terminal, which sends JLine's
usual terminal probes (DSR/DECRQM) and reads the replies itself, as groovysh
does when it starts.
> The shell Logger never prints ANSI colors because IO looks for the old Jansi
> ----------------------------------------------------------------------------
>
> Key: GROOVY-12784
> URL: https://issues.apache.org/jira/browse/GROOVY-12784
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {{org.codehaus.groovy.tools.shell.IO}} decides whether to render ANSI by
> looking for {{org.fusesource.jansi.AnsiRenderWriter}}. Since GROOVY-8162
> Groovy ships JLine's Jansi ({{org.jline:jansi}}) instead, which has no such
> class, so {{IO.ansiSupported}} is always {{false}} and the shell {{Logger}}
> (used by groovydoc) never colors its DEBUG, WARN and ERROR prefixes, although
> {{Logger}} already renders them with {{org.jline.jansi.Ansi}}.
> {{IO}} should detect JLine's Jansi and render through its {{AnsiConsole}},
> for the JVM's own standard output and error only, so output redirected to a
> file or a pipe stays plain. The {{jansi.mode}} system property ({{force}} /
> {{strip}}) still applies.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)