-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Comments
The ANSI/VT escape sequences are not enabled by default in the Windows console. You need to set a registry key ( |
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. |
@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. |
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 :) |
My system:
![mysys](https://user-images.githubusercontent.com/24580002/41799730-2f78ffa6-7638-11e8-8790-e1c1d300dc13.PNG)
My Windows build number:
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](https://user-images.githubusercontent.com/24580002/41799401-02b90476-7637-11e8-9df4-cebdada79756.PNG)
Here's the command and output (WITH ansicon installed):
![withansi](https://user-images.githubusercontent.com/24580002/41799428-29821f3e-7637-11e8-8a55-9c54c5cdfa12.PNG)
Here is the what I have installed to make the color output of the logs render correctly:
https://github.com/adoxa/ansicon
Shouldn't the colors render correctly in the console without ansicon installed?
FYI, I get the same results in both cmd & powershell.
Here is a link to gorm's logger, written in Go (shows the formatting used):
https://github.com/jinzhu/gorm/blob/master/logger.go
The text was updated successfully, but these errors were encountered: