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

fix: stop color mode on windows cmd/powershell #4076

Merged
merged 4 commits into from
Sep 18, 2019

Conversation

maxandersen
Copy link
Member

Why:

  • by default ANSI colors are not enabled for cmd/powershell
    on Windows 10 machines so users will by default get garbled output.

This change addreses the need by:

  • Detect when running on Windows and NOT in known working windows
    emulators and there not enable colors.

Solves #1029

@maxandersen
Copy link
Member Author

Work in progress - just opened PR to get feedback on general idea.

My windows virtual machine box been building quarkus master (without tests) for the last 30 minutes and its over midnight so i'm going to sleep while my laptop spends some cpu cycles.

Tomorrow i'll test and verify it works as expected.

@dmlloyd
Copy link
Member

dmlloyd commented Sep 17, 2019

You can create a pull request as a "draft" PR. It's a relatively recent feature. When you go to open the pull request, the "create pull request" button has a dropdown menu on it; choose "open as draft" from there.

Why:

 * by default ANSI colors are not enabled for cmd/powershell
   on Windows 10 machines so users will by default get garbled output.

This change addreses the need by:

 * Detect when running on Windows and NOT in known working windows
   emulators and there not enable colors.

Solves quarkusio#1029
@maxandersen maxandersen force-pushed the windows_colors_gh1029 branch 2 times, most recently from d937a73 to e71e652 Compare September 18, 2019 13:56
@maxandersen
Copy link
Member Author

Okey, removing the WIP moniker as i finally got this tested.

Had to remove System.console() test under windows as when running on cygwin console is null.

2019-09-18_15-58-26

screenshot above shows same app running in cygwin (left) and plain cmd.exe (right).

Optimally I would like to have a way for users to force color on in case they have set the registry flag. Suggestions welcome :)

@@ -35,6 +36,29 @@
*/
@Recorder
public class LoggingSetupRecorder {

static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("win");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the sake of avoiding possible NPE, it would be nice to use getProperty("os.name", "Linux"), WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that happens you are on a non-java vm :)

@maxandersen maxandersen changed the title WIP: fix: stop color mode on windows cmd/powershell fix: stop color mode on windows cmd/powershell Sep 18, 2019
Why:

 * Windows cygwin has no console thus colors are disabled without reason.

This change addreses the need by:

 * ignore System.console() test on Windows, keep it everywhere else.
Copy link
Member

@dmlloyd dmlloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Close enough, we can improve in a subsequent PR!

Why:

 * Windows is a pain when it comes to guessing color capabilities.
   Its many terminals has too many variances for our guesses to be
   always right.

This change addreses the need by:

 * Make quarkus.log.console.color optional allowing users to force
   on/off and when left unset quarkus will take a best guess.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants