logger: allow overriding colour output for fancy consoles on Windows

This commit is contained in:
Adrian Gallagher
2019-01-25 11:21:38 +11:00
parent 63d0fd722a
commit c2b91edace
2 changed files with 7 additions and 6 deletions

View File

@@ -59,7 +59,7 @@ func setDefaultOutputs() {
// colorOutput() sets the prefix of each log type to matching colour
// TODO: add windows support
func colourOutput() {
if runtime.GOOS != "windows" {
if runtime.GOOS != "windows" || Logger.ColourOutputOverride {
debugLogger.SetPrefix("\033[34m[DEBUG]\033[0m: ")
infoLogger.SetPrefix("\033[32m[INFO]\033[0m: ")
warnLogger.SetPrefix("\033[33m[WARN]\033[0m: ")

View File

@@ -8,11 +8,12 @@ import (
// Logging struct that holds all user configurable options for the logger
type Logging struct {
Enabled *bool `json:"enabled,omitempty"`
File string `json:"file"`
ColourOutput bool `json:"colour"`
Level string `json:"level"`
Rotate bool `json:"rotate"`
Enabled *bool `json:"enabled,omitempty"`
File string `json:"file"`
ColourOutput bool `json:"colour"`
ColourOutputOverride bool `json:"colourOverride,omitempty"`
Level string `json:"level"`
Rotate bool `json:"rotate"`
}
var (