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 {
|
type PrettyZerologWriter struct {
|
||||||
wd string
|
wd string
|
||||||
|
wasLastLogMultiline bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type PrettyLogEntry struct {
|
type PrettyLogEntry struct {
|
||||||
|
@ -87,6 +88,7 @@ func NewPrettyZerologWriter() *PrettyZerologWriter {
|
||||||
wd, _ := os.Getwd()
|
wd, _ := os.Getwd()
|
||||||
return &PrettyZerologWriter{
|
return &PrettyZerologWriter{
|
||||||
wd: wd,
|
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
|
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
|
var b strings.Builder
|
||||||
|
if isMultiline || w.wasLastLogMultiline {
|
||||||
b.WriteString("---------------------------------------\n")
|
b.WriteString("---------------------------------------\n")
|
||||||
|
}
|
||||||
b.WriteString(pretty.Timestamp)
|
b.WriteString(pretty.Timestamp)
|
||||||
b.WriteString(" ")
|
b.WriteString(" ")
|
||||||
if pretty.Level != "" {
|
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()))
|
return os.Stderr.Write([]byte(b.String()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue