fix: fix log output (#2424)

master
chen quan 2 years ago committed by GitHub
parent 1b344a8851
commit 68e15360c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,12 +1,12 @@
package logx
import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"path"
"strings"
"sync"
"sync/atomic"
@ -329,7 +329,7 @@ func writePlainAny(writer io.Writer, level string, val interface{}, fields ...st
}
func writePlainText(writer io.Writer, level, msg string, fields ...string) {
var buf strings.Builder
var buf bytes.Buffer
buf.WriteString(getTimestamp())
buf.WriteByte(plainEncodingSep)
buf.WriteString(level)
@ -345,13 +345,14 @@ func writePlainText(writer io.Writer, level, msg string, fields ...string) {
return
}
if _, err := fmt.Fprint(writer, buf.String()); err != nil {
if _, err := writer.Write(buf.Bytes()); err != nil {
log.Println(err.Error())
}
}
func writePlainValue(writer io.Writer, level string, val interface{}, fields ...string) {
var buf strings.Builder
var buf bytes.Buffer
buf.WriteString(getTimestamp())
buf.WriteByte(plainEncodingSep)
buf.WriteString(level)
@ -371,7 +372,7 @@ func writePlainValue(writer io.Writer, level string, val interface{}, fields ...
return
}
if _, err := fmt.Fprint(writer, buf.String()); err != nil {
if _, err := writer.Write(buf.Bytes()); err != nil {
log.Println(err.Error())
}
}

Loading…
Cancel
Save