github.com/v2pro/plz@v0.0.0-20221028024117-e5f9aec5b631/countlog/output/compact/error.go (about)

     1  package compact
     2  
     3  import "github.com/v2pro/plz/countlog/spi"
     4  
     5  type errorFormatter struct {
     6  }
     7  
     8  func (formatter *errorFormatter) Format(space []byte, event *spi.Event) []byte {
     9  	if event.Error == nil {
    10  		return space
    11  	}
    12  	msg := event.Error.Error()
    13  	if msg == "" {
    14  		return space
    15  	}
    16  	space = append(space, " error:"...)
    17  	return append(space, msg...)
    18  }