File: format.go

package info (click to toggle)
docker-buildx 0.13.1%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,356 kB
  • sloc: sh: 299; makefile: 87
file content (23 lines) | stat: -rw-r--r-- 444 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package logutil

import (
	"bytes"
	"fmt"
	"strings"

	"github.com/sirupsen/logrus"
)

type Formatter struct {
	logrus.TextFormatter
}

func (f *Formatter) Format(entry *logrus.Entry) ([]byte, error) {
	msg := bytes.NewBuffer(nil)
	fmt.Fprintf(msg, "%s: %s", strings.ToUpper(entry.Level.String()), entry.Message)
	if v, ok := entry.Data[logrus.ErrorKey]; ok {
		fmt.Fprintf(msg, ": %v", v)
	}
	fmt.Fprintf(msg, "\n")
	return msg.Bytes(), nil
}