update lead string position for glog

This commit is contained in:
John
2019-06-07 23:00:34 +08:00
parent a908e4d4b1
commit c0c97b76fb
2 changed files with 9 additions and 8 deletions

View File

@ -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(' ')

View File

@ -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")
}