From 8baa02ec404b7610be0c93c105d8487c6dd9e418 Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Tue, 12 Sep 2023 18:09:09 +0200 Subject: [PATCH] Fixed jANSI segfaulting the JVM when there is no console --- src/main/java/net/raphimc/viaproxy/util/logging/Logger.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/raphimc/viaproxy/util/logging/Logger.java b/src/main/java/net/raphimc/viaproxy/util/logging/Logger.java index 9017d92..2b05bff 100644 --- a/src/main/java/net/raphimc/viaproxy/util/logging/Logger.java +++ b/src/main/java/net/raphimc/viaproxy/util/logging/Logger.java @@ -36,7 +36,9 @@ public class Logger { public static final PrintStream SYSERR = System.err; public static void setup() { - AnsiConsole.systemInstall(); + if (System.console() != null) { // jANSI is the best lib. If there is no console it just segfaults the JVM process. Thanks! + AnsiConsole.systemInstall(); + } System.setErr(new LoggerPrintStream("STDERR", SYSERR)); System.setOut(new LoggerPrintStream("STDOUT", SYSOUT)); }