-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LOGBACK-1392 Improve support for the JANSI library in ConsoleAppender #414
Conversation
57d50d9
to
6ef52f5
Compare
@adutra Can you create a Jira issue for this PR please? |
@ceki of course, there you go: LOGBACK-1392 |
697e644
to
66d6432
Compare
Motivation: The Jansi library provides an AnsiPrintStream that intercepts ANSI sequences and allows the application to react to them accordingly. Jansi is compatible with a variety of terminals, including xterm-like terminals for Windows like Mintty and MinGW. Jansi has a good algorithm to detect whether or not ANSI sequences will be correctly interpreted or not, and if not, its default behavior is to filter out such sequences. Logback's ConsoleAppender has a withJansi option. Unfortunately, Logback bypasses Jansi's detection algorithm and boldly assumes that if the OS is Windows, then the terminal is a DOS prompt. So while DOS prompts get colored, terminals like Mintty or MinGW not only lose their coloring but are sent DOS escape sequences that they can't interpret. Modifications: - Amend ConsoleAppender so that when withJansi is true, then all OutputStreams are wrapped in an AnsiPrintStream, effectively delegating to the JANSI library the decision to filter out ANSI escape sequences or not, depending on the terminal capability. This also allows users to disable or customize the coloring behavior by using system properties recognized by JANSI, such as jansi.strip. - Amend the documentation and stress that the JANSI library is the recommended solution for Windows systems, as well as for cross-platform deployments that include a mix of Windows and non-Windows systems.
66d6432
to
58f15b5
Compare
Is there plan to integrate this PR in next version of LOGBACK ? |
More than one year and this PR is still not integrated any reason of that ? |
Looks quite good. My apologies for the delay. If the code is not merged by this Thursday evening, please remind me once again. |
Thx 🙏 ! |
Is there any chance this could be backported in 1.2.x branch ? Out of topic question ? do you have a vague idea about when the 1.3.0 will be released ? |
I finally find a workaround about this using Picocli heuristic : https://stackoverflow.com/a/68633212/5088764 (in my case that solve the java8 and Jansi dependency but It would be better that logback has its own heuristic like requested in https://jira.qos.ch/browse/LOGBACK-1430) |
Motivation:
The Jansi library provides an AnsiPrintStream that intercepts ANSI
sequences and allows the application to react to them accordingly.
Jansi is compatible with a variety of terminals, including xterm-like
terminals for Windows like Mintty and MinGW.
Jansi has a good algorithm to detect whether or not ANSI
sequences will be correctly interpreted or not, and if not, its default
behavior is to filter out such sequences.
Logback's ConsoleAppender has a withJansi option. Unfortunately,
Logback bypasses Jansi's detection algorithm and boldly
assumes that if the OS is Windows, then the terminal is a DOS prompt.
So while DOS prompts get colored, terminals like Mintty or MinGW not
only lose their coloring but are sent DOS escape sequences that they
can't interpret.
Modifications:
OutputStreams are wrapped in an AnsiPrintStream, effectively delegating
to the JANSI library the decision to filter out ANSI escape sequences
or not, depending on the terminal capability. This also allows users
to disable or customize the coloring behavior by using system properties
recognized by JANSI, such as jansi.strip.
recommended solution for Windows systems, as well as for cross-platform
deployments that include a mix of Windows and non-Windows systems.