|
|
@ -307,29 +307,7 @@ func writePlainAny(writer io.Writer, level string, val interface{}, fields ...st
|
|
|
|
case fmt.Stringer:
|
|
|
|
case fmt.Stringer:
|
|
|
|
writePlainText(writer, level, v.String(), fields...)
|
|
|
|
writePlainText(writer, level, v.String(), fields...)
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
var buf strings.Builder
|
|
|
|
writePlainValue(writer, level, v, fields...)
|
|
|
|
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
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, item := range fields {
|
|
|
|
|
|
|
|
buf.WriteByte(plainEncodingSep)
|
|
|
|
|
|
|
|
buf.WriteString(item)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
buf.WriteByte('\n')
|
|
|
|
|
|
|
|
if writer == nil {
|
|
|
|
|
|
|
|
log.Println(buf.String())
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _, err := fmt.Fprint(writer, buf.String()); err != nil {
|
|
|
|
|
|
|
|
log.Println(err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -354,3 +332,29 @@ func writePlainText(writer io.Writer, level, msg string, fields ...string) {
|
|
|
|
log.Println(err.Error())
|
|
|
|
log.Println(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
if err := json.NewEncoder(&buf).Encode(val); err != nil {
|
|
|
|
|
|
|
|
log.Println(err.Error())
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, item := range fields {
|
|
|
|
|
|
|
|
buf.WriteByte(plainEncodingSep)
|
|
|
|
|
|
|
|
buf.WriteString(item)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
buf.WriteByte('\n')
|
|
|
|
|
|
|
|
if writer == nil {
|
|
|
|
|
|
|
|
log.Println(buf.String())
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _, err := fmt.Fprint(writer, buf.String()); err != nil {
|
|
|
|
|
|
|
|
log.Println(err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|