|
|
|
@ -307,16 +307,17 @@ func writePlainAny(writer io.Writer, level string, val interface{}, fields ...st
|
|
|
|
|
case fmt.Stringer:
|
|
|
|
|
writePlainText(writer, level, v.String(), fields...)
|
|
|
|
|
default:
|
|
|
|
|
writePlainValue(writer, level, v, fields...)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func writePlainText(writer io.Writer, level, msg string, fields ...string) {
|
|
|
|
|
var buf strings.Builder
|
|
|
|
|
buf.WriteString(getTimestamp())
|
|
|
|
|
buf.WriteByte(plainEncodingSep)
|
|
|
|
|
buf.WriteString(level)
|
|
|
|
|
buf.WriteByte(plainEncodingSep)
|
|
|
|
|
if err := json.NewEncoder(&buf).Encode(val); err != nil {
|
|
|
|
|
log.Println(err.Error())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buf.WriteString(msg)
|
|
|
|
|
for _, item := range fields {
|
|
|
|
|
buf.WriteByte(plainEncodingSep)
|
|
|
|
|
buf.WriteString(item)
|
|
|
|
@ -331,15 +332,18 @@ func writePlainAny(writer io.Writer, level string, val interface{}, fields ...st
|
|
|
|
|
log.Println(err.Error())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func writePlainText(writer io.Writer, level, msg string, fields ...string) {
|
|
|
|
|
func writePlainValue(writer io.Writer, level string, val interface{}, fields ...string) {
|
|
|
|
|
var buf strings.Builder
|
|
|
|
|
buf.WriteString(getTimestamp())
|
|
|
|
|
buf.WriteByte(plainEncodingSep)
|
|
|
|
|
buf.WriteString(level)
|
|
|
|
|
buf.WriteByte(plainEncodingSep)
|
|
|
|
|
buf.WriteString(msg)
|
|
|
|
|
if err := json.NewEncoder(&buf).Encode(val); err != nil {
|
|
|
|
|
log.Println(err.Error())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, item := range fields {
|
|
|
|
|
buf.WriteByte(plainEncodingSep)
|
|
|
|
|
buf.WriteString(item)
|
|
|
|
|