fusesource / jansi

Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.
http://fusesource.github.io/jansi/
Apache License 2.0
1.11k stars 140 forks source link

Allow interception of AnsiConsole's output #228

Closed NilsRenaud closed 2 years ago

NilsRenaud commented 2 years ago

This commit : https://github.com/fusesource/jansi/commit/57aa84d4120395922458f61f20e741198f051087 Has replaced System.out and System.err by FileDescriptor.out and FileDescriptor.err.

Although this seems related to Windows support, it is now impossible to test AnsiConsole when integrated in a project. This is why Logback project is stuck in version 1.18 of JANSI.

As an example, here is a PR trying to upgrade JANSI version in logback : https://github.com/qos-ch/logback/pull/542/files

A possible solution could be to specify the PrintStream to use to AnsiConsole, or to use System.out/System.err back instead of FileDescriptor's one.

NilsRenaud commented 2 years ago

@gnodet could you please explain the choice of using FileDescriptor.out/err instead of System.out/err ? Is it possible to come back to System.out/err ?

Thanks in advance !

gnodet commented 2 years ago

It's not really doable. However, your test can be fixed with the following: https://github.com/gnodet/logback/commit/e60cd353b834f7e656345ad403f0cfed128e2863