Commit a0434323 authored by Pelle Johnsen's avatar Pelle Johnsen

Change option name from noColor to color

Still same default behavior (with color)
parent 7f888e3d
...@@ -47,9 +47,9 @@ var colors = []brush{ ...@@ -47,9 +47,9 @@ var colors = []brush{
// consoleWriter implements LoggerInterface and writes messages to terminal. // consoleWriter implements LoggerInterface and writes messages to terminal.
type consoleWriter struct { type consoleWriter struct {
lg *log.Logger lg *log.Logger
Level int `json:"level"` Level int `json:"level"`
NoColor bool `json:"noColor"` Color bool `json:"color"`
} }
// NewConsole create ConsoleWriter returning as LoggerInterface. // NewConsole create ConsoleWriter returning as LoggerInterface.
...@@ -57,6 +57,7 @@ func NewConsole() Logger { ...@@ -57,6 +57,7 @@ func NewConsole() Logger {
cw := &consoleWriter{ cw := &consoleWriter{
lg: log.New(os.Stdout, "", 0), lg: log.New(os.Stdout, "", 0),
Level: LevelDebug, Level: LevelDebug,
Color: true,
} }
return cw return cw
} }
...@@ -76,7 +77,7 @@ func (c *consoleWriter) WriteMsg(when time.Time, msg string, level int) error { ...@@ -76,7 +77,7 @@ func (c *consoleWriter) WriteMsg(when time.Time, msg string, level int) error {
return nil return nil
} }
msg = formatLogTime(when) + msg msg = formatLogTime(when) + msg
if runtime.GOOS == "windows" || c.NoColor { if runtime.GOOS == "windows" || !c.Color {
c.lg.Println(msg) c.lg.Println(msg)
return nil return nil
} }
......
...@@ -46,6 +46,6 @@ func TestConsole(t *testing.T) { ...@@ -46,6 +46,6 @@ func TestConsole(t *testing.T) {
// Test console without color // Test console without color
func TestConsoleNoColor(t *testing.T) { func TestConsoleNoColor(t *testing.T) {
log := NewLogger(100) log := NewLogger(100)
log.SetLogger("console", `{"noColor":true}`) log.SetLogger("console", `{"color":false}`)
testConsoleCalls(log) testConsoleCalls(log)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment