Removed dashed line between single-line log outputs
This commit is contained in:
parent
7a01ddae66
commit
490c82940a
|
@ -55,7 +55,8 @@ func With() zerolog.Context {
|
|||
}
|
||||
|
||||
type PrettyZerologWriter struct {
|
||||
wd string
|
||||
wd string
|
||||
wasLastLogMultiline bool
|
||||
}
|
||||
|
||||
type PrettyLogEntry struct {
|
||||
|
@ -86,7 +87,8 @@ var ColorFromLevel = map[string]string{
|
|||
func NewPrettyZerologWriter() *PrettyZerologWriter {
|
||||
wd, _ := os.Getwd()
|
||||
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
|
||||
})
|
||||
|
||||
isMultiline := (pretty.Error != "" || pretty.StackTrace != nil || pretty.OtherFields != nil)
|
||||
|
||||
var b strings.Builder
|
||||
b.WriteString("---------------------------------------\n")
|
||||
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