1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-25 22:41:29 +00:00

make more fast

This commit is contained in:
JessonChan 2016-02-03 15:03:37 +08:00
parent a1cb000701
commit 9806a43783

View File

@ -119,10 +119,11 @@ func (w *fileLogWriter) WriteMsg(when time.Time, msg string, level int) error {
return nil return nil
} }
h, d := formatTimeHeader(when) h, d := formatTimeHeader(when)
msg = string(h) + msg + "\n"
if w.Rotate { if w.Rotate {
if w.needRotate(len(h)+len(msg)+1, d) { if w.needRotate(len(msg), d) {
w.Lock() w.Lock()
if w.needRotate(len(h)+len(msg)+1, d) { if w.needRotate(len(msg), d) {
if err := w.doRotate(when); err != nil { if err := w.doRotate(when); err != nil {
fmt.Fprintf(os.Stderr, "FileLogWriter(%q): %s\n", w.Filename, err) fmt.Fprintf(os.Stderr, "FileLogWriter(%q): %s\n", w.Filename, err)
} }
@ -132,7 +133,7 @@ func (w *fileLogWriter) WriteMsg(when time.Time, msg string, level int) error {
} }
w.Lock() w.Lock()
_, err := w.fileWriter.Write(append(append(h, msg...), '\n')) _, err := w.fileWriter.Write([]byte(msg))
if err == nil { if err == nil {
w.maxLinesCurLines++ w.maxLinesCurLines++
w.maxSizeCurSize += len(msg) w.maxSizeCurSize += len(msg)