mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 11:10:57 +00:00
Change option name from noColor to color
Still same default behavior (with color)
This commit is contained in:
parent
7f888e3d18
commit
a043432398
@ -49,7 +49,7 @@ var colors = []brush{
|
||||
type consoleWriter struct {
|
||||
lg *log.Logger
|
||||
Level int `json:"level"`
|
||||
NoColor bool `json:"noColor"`
|
||||
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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user