From bcac4bb8e3631e77fe1a0e0d6fd312a4f3c1b099 Mon Sep 17 00:00:00 2001 From: youngsterxyf Date: Mon, 25 Jan 2016 20:53:25 +0800 Subject: [PATCH] accept @JessonChan suggestion --- logs/conn.go | 3 +-- logs/console.go | 5 +---- logs/file.go | 3 +-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/logs/conn.go b/logs/conn.go index 2a29688a..5d78467b 100644 --- a/logs/conn.go +++ b/logs/conn.go @@ -64,8 +64,7 @@ func (c *connWriter) WriteMsg(when time.Time, msg string, level int) error { defer c.innerWriter.Close() } - logTimeStr := formatLogTime(when) - msg = logTimeStr + msg + msg = formatLogTime(when) + msg c.lg.Println(msg) return nil diff --git a/logs/console.go b/logs/console.go index 48d1e5b2..e6da0df9 100644 --- a/logs/console.go +++ b/logs/console.go @@ -74,10 +74,7 @@ func (c *consoleWriter) WriteMsg(when time.Time, msg string, level int) error { if level > c.Level { return nil } - - logTimeStr := formatLogTime(when) - msg = logTimeStr + msg - + msg = formatLogTime(when) + msg if goos := runtime.GOOS; goos == "windows" { c.lg.Println(msg) return nil diff --git a/logs/file.go b/logs/file.go index 16bf29c2..f277317c 100644 --- a/logs/file.go +++ b/logs/file.go @@ -121,8 +121,7 @@ func (w *fileLogWriter) WriteMsg(when time.Time, msg string, level int) error { //2016/01/12 21:34:33 // now := time.Now() d := when.Day() - logTimeStr := formatLogTime(when) - msg = logTimeStr + msg + "\n" + msg = formatLogTime(when) + msg + "\n" if w.Rotate { if w.needRotate(len(msg), d) {