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

     1  package hrf
     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, "\n\x1b[90;1merror: "...)
    17  	space = append(space, msg...)
    18  	space = append(space, "\x1b[0m"...)
    19  	return space
    20  }