Removed dashed line between single-line log outputs
This commit is contained in:
parent
7a01ddae66
commit
490c82940a
|
@ -56,6 +56,7 @@ func With() zerolog.Context {
|
|||
|
||||
type PrettyZerologWriter struct {
|
||||
wd string
|
||||
wasLastLogMultiline bool
|
||||
}
|
||||
|
||||
type PrettyLogEntry struct {
|
||||
|
@ -87,6 +88,7 @@ func NewPrettyZerologWriter() *PrettyZerologWriter {
|
|||
wd, _ := os.Getwd()
|
||||
return &PrettyZerologWriter{
|
||||
wd: wd,
|
||||
wasLastLogMultiline: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,8 +126,12 @@ func (w *PrettyZerologWriter) Write(p []byte) (int, error) {
|
|||
return strings.Compare(pretty.OtherFields[i].Name, pretty.OtherFields[j].Name) < 0
|
||||
})
|
||||
|
||||
isMultiline := (pretty.Error != "" || pretty.StackTrace != nil || pretty.OtherFields != nil)
|
||||
|
||||
var b strings.Builder
|
||||
if isMultiline || w.wasLastLogMultiline {
|
||||
b.WriteString("---------------------------------------\n")
|
||||
}
|
||||
b.WriteString(pretty.Timestamp)
|
||||
b.WriteString(" ")
|
||||
if pretty.Level != "" {
|
||||
|
@ -170,6 +176,8 @@ func (w *PrettyZerologWriter) Write(p []byte) (int, error) {
|
|||
}
|
||||
}
|
||||
|
||||
w.wasLastLogMultiline = isMultiline
|
||||
|
||||
return os.Stderr.Write([]byte(b.String()))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue