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

Gorm database logs not rendering colors properly unless ansicon is installed #211

Closed
benfaught opened this issue Jun 22, 2018 · 5 comments
Closed

Comments

@benfaught
Copy link

benfaught commented Jun 22, 2018

My system:
mysys

My Windows build number:

  • Microsoft Windows [Version 10.0.17134.112]

I'm running golang server and printing database logs to console using gorm.
specifically using this method: https://godoc.org/github.com/jinzhu/gorm#DB.LogMode

Here's the command and output (without ansicon installed):
woansi

Here's the command and output (WITH ansicon installed):
withansi

@j4james
Copy link
Collaborator

j4james commented Jun 30, 2018

The ANSI/VT escape sequences are not enabled by default in the Windows console. You need to set a registry key (HKEY_CURRENT_USER\Console\VirtualTerminalLevel) to turn on that functionality. I'm not sure if it is officially documented anyway, but it was explained in the comments of one of the WSL issues. See here.

@benfaught
Copy link
Author

Yes! Worked Perfectly. Look at those beautiful colorful logs 😍 Thank You!
beautylogs

@zadjii-msft
Copy link
Member

For the record, the reg key is a bit of a hack, (and honestly I forgot it was there). Applications on windows that want to enable the VT support should be using SetConsoleMode with the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag, so that all users of the application will get the same behavior.

@j4james
Copy link
Collaborator

j4james commented Jul 2, 2018

@zadjii-msft If you're writing a cross-platform app, though, it's a bit disappointing being told that you have to add platform-specific API calls to your code just to get functionality that works out of the box in other operating systems (including older versions of Windows back in the ansi.sys days). Personally I would just have stuck with ansicon if that registry option wasn't available, so I hope you aren't planning on removing it.

@zadjii-msft
Copy link
Member

Aye, but unfortunately our ultimate loyalty is to supporting backwards compat, and for whatever reason we can't just enable it by default :(.

However, you can be sure that means we're not pulling the reg key either :)

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

No branches or pull requests

3 participants