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

Graceful failure #204

Closed mattjlewis closed 2 years ago

mattjlewis commented 3 years ago

Is it possible for jansi to fail gracefully if the native library fails to load? I.e. ignore any colour output requests and output plain text instead.

gnodet commented 3 years ago

Is that related to #207 ?

mattjlewis commented 3 years ago

Yes. I initially removed the call to AnsiConole.systemInstall as I primarily run my apps on Linux which don't need this (AnsiConsole.systemInstall() fails on ARMv6). However, I have recently been running some applications from within my IDE (Eclipse) and was annoyed to see the control characters. I now do this:

        // Attempt to initialise Jansi
        try {
            AnsiConsole.systemInstall();
        } catch (Throwable t) {
            // Ignore
            Logger.trace(t, "Jansi native library not available on this platform: {}", t);
        }

BTW I have setup Docker based compilation for diozero that supports x86, ARMv6, ARMv7 and AArch64 - I basically compile GCC 8 for ARMv6 and use standard tools for the rest. https://github.com/mattjlewis/diozero/tree/main/docker

michael-o commented 3 years ago

See here: https://issues.apache.org/jira/projects/MNG/issues/MNG-7165