From c0c97b76fb485dc04e7b55bcc4e877fbf6ffa5b7 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 7 Jun 2019 23:00:34 +0800 Subject: [PATCH] update lead string position for glog --- g/os/glog/glog_logger.go | 13 +++++++------ geg/os/glog/glog_line.go | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/g/os/glog/glog_logger.go b/g/os/glog/glog_logger.go index 7b9329c5f..5d6562d98 100644 --- a/g/os/glog/glog_logger.go +++ b/g/os/glog/glog_logger.go @@ -243,6 +243,13 @@ func (l *Logger) print(std io.Writer, lead string, value...interface{}) { if len(timeFormat) > 0 { buffer.WriteString(time.Now().Format(timeFormat)) } + // Lead string. + if len(lead) > 0 { + buffer.WriteString(lead) + if len(value) > 0 { + buffer.WriteByte(' ') + } + } // Caller path. callerPath := "" if l.flags & F_FILE_LONG > 0 { @@ -259,12 +266,6 @@ func (l *Logger) print(std io.Writer, lead string, value...interface{}) { buffer.WriteString(l.prefix + " ") } } - if len(lead) > 0 { - buffer.WriteString(lead) - if len(value) > 0 { - buffer.WriteByte(' ') - } - } for k, v := range value { if k > 0 { buffer.WriteByte(' ') diff --git a/geg/os/glog/glog_line.go b/geg/os/glog/glog_line.go index 41d2e0779..ab28cb622 100644 --- a/geg/os/glog/glog_line.go +++ b/geg/os/glog/glog_line.go @@ -5,6 +5,6 @@ import ( ) func main() { - glog.Line().Println("this is the short file name with its line number") - glog.Line(true).Println("lone file name with line number") + glog.Line().Debug("this is the short file name with its line number") + glog.Line(true).Debug("lone file name with line number") }