From a0434323982ac73a406177bec245b3286e484378 Mon Sep 17 00:00:00 2001 From: Pelle Johnsen Date: Thu, 28 Jan 2016 07:50:07 +0100 Subject: [PATCH] Change option name from noColor to color Still same default behavior (with color) --- logs/console.go | 9 +++++---- logs/console_test.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/logs/console.go b/logs/console.go index 871e7972..d7ed8d8e 100644 --- a/logs/console.go +++ b/logs/console.go @@ -47,9 +47,9 @@ var colors = []brush{ // consoleWriter implements LoggerInterface and writes messages to terminal. type consoleWriter struct { - lg *log.Logger - Level int `json:"level"` - NoColor bool `json:"noColor"` + lg *log.Logger + Level int `json:"level"` + Color bool `json:"color"` } // NewConsole create ConsoleWriter returning as LoggerInterface. @@ -57,6 +57,7 @@ func NewConsole() Logger { cw := &consoleWriter{ lg: log.New(os.Stdout, "", 0), Level: LevelDebug, + Color: true, } return cw } @@ -76,7 +77,7 @@ func (c *consoleWriter) WriteMsg(when time.Time, msg string, level int) error { return nil } msg = formatLogTime(when) + msg - if runtime.GOOS == "windows" || c.NoColor { + if runtime.GOOS == "windows" || !c.Color { c.lg.Println(msg) return nil } diff --git a/logs/console_test.go b/logs/console_test.go index 45211588..04f2bd7e 100644 --- a/logs/console_test.go +++ b/logs/console_test.go @@ -46,6 +46,6 @@ func TestConsole(t *testing.T) { // Test console without color func TestConsoleNoColor(t *testing.T) { log := NewLogger(100) - log.SetLogger("console", `{"noColor":true}`) + log.SetLogger("console", `{"color":false}`) testConsoleCalls(log) }