Skip to content
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

[MNG-6380] Option -Dstyle.color=always doesn't force color output #67

Merged
merged 1 commit into from Apr 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,6 +21,7 @@

import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.AnsiConsole;
import org.fusesource.jansi.AnsiMode;

/**
* Colored message utils, to manage colors consistently across plugins (only if Maven version is at least 3.5.0).
Expand Down Expand Up @@ -81,17 +82,13 @@ public static void systemUninstall()
// hook can only set when JANSI is true
if ( shutdownHook != null )
{
// if out and system_out are same instance again, ansi is assumed to be uninstalled
if ( AnsiConsole.out == AnsiConsole.system_out )
try
{
try
{
Runtime.getRuntime().removeShutdownHook( shutdownHook );
}
catch ( IllegalStateException ex )
{
// ignore - VM is already shutting down
}
Runtime.getRuntime().removeShutdownHook( shutdownHook );
}
catch ( IllegalStateException ex )
{
// ignore - VM is already shutting down
}
}
}
Expand All @@ -113,7 +110,19 @@ public static void setColorEnabled( boolean flag )
{
if ( JANSI )
{
AnsiConsole.out().setMode( flag ? AnsiMode.Force : AnsiMode.Strip );
Ansi.setEnabled( flag );
System.setProperty( AnsiConsole.JANSI_MODE,
flag ? AnsiConsole.JANSI_MODE_FORCE : AnsiConsole.JANSI_MODE_STRIP );
boolean installed = AnsiConsole.isInstalled();
while ( AnsiConsole.isInstalled() )
{
AnsiConsole.systemUninstall();
}
if ( installed )
{
AnsiConsole.systemInstall();
}
}
}

Expand Down Expand Up @@ -194,7 +203,10 @@ public void run()
{
synchronized ( STARTUP_SHUTDOWN_MONITOR )
{
doSystemUninstall();
while ( AnsiConsole.isInstalled() )
{
doSystemUninstall();
}
}
}
};
Expand Down