1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-15 09:21:02 +00:00
This commit is contained in:
youngsterxyf
2016-01-23 16:24:58 +08:00
parent af346e871b
commit ecf24640fd
6 changed files with 88 additions and 68 deletions

View File

@ -19,6 +19,7 @@ import (
"log"
"os"
"runtime"
"time"
)
// brush is a color join function
@ -53,7 +54,7 @@ type consoleWriter struct {
// NewConsole create ConsoleWriter returning as LoggerInterface.
func NewConsole() Logger {
cw := &consoleWriter{
lg: log.New(os.Stdout, "", log.Ldate|log.Ltime),
lg: log.New(os.Stdout, "", 0),
Level: LevelDebug,
}
return cw
@ -69,10 +70,14 @@ func (c *consoleWriter) Init(jsonconfig string) error {
}
// WriteMsg write message in console.
func (c *consoleWriter) WriteMsg(msg string, level int) error {
func (c *consoleWriter) WriteMsg(when time.Time, msg string, level int) error {
if level > c.Level {
return nil
}
logTimeStr := formatLogTime(when)
msg = logTimeStr + msg
if goos := runtime.GOOS; goos == "windows" {
c.lg.Println(msg)
return nil