func (tf *TextFormatter) Format(e *log.Entry) (data []byte, err error) {
	defer func() {
		if r := recover(); r != nil {
			data = append([]byte("panic in log formatter\n"), rundebug.Stack()...)
			return
		}
	}()
	formatCaller := tf.FormatCaller
	if formatCaller == nil {
		formatCaller = formatCallerWithPathAndLine
	}
	caller := formatCaller()
	w := &writer{}
	if !tf.DisableTimestamp {
		w.writeField(e.Time.Format(time.RFC3339), noColor)
	}
	color := noColor
	if tf.EnableColors {
		switch e.Level {
		case log.DebugLevel:
			color = gray
		case log.WarnLevel:
			color = yellow
		case log.ErrorLevel, log.FatalLevel, log.PanicLevel:
			color = red
		default:
			color = blue
		}
	}
	w.writeField(strings.ToUpper(padMax(e.Level.String(), DefaultLevelPadding)), color)
	padding := DefaultComponentPadding
	if tf.ComponentPadding != 0 {
		padding = tf.ComponentPadding
	}
	if w.Len() > 0 {
		w.WriteByte(' ')
	}
	value := e.Data[Component]
	var component string
	if reflect.ValueOf(value).IsValid() {
		component = fmt.Sprintf("[%v]", value)
	}
	component = strings.ToUpper(padMax(component, padding))
	if component[len(component)-1] != ' ' {
		component = component[:len(component)-1] + "]"
	}
	w.WriteString(component)
	if e.Message != "" {
		w.writeField(e.Message, noColor)
	}
	if len(e.Data) > 0 {
		w.writeMap(e.Data)
	}
	if caller != "" {
		w.writeField(caller, noColor)
	}
	w.WriteByte('\n')
	data = w.Bytes()
	return
}
Format implements logrus.Formatter interface and adds file and line
package trace
import (
	"bytes"
	"fmt"
	"io"
	"os"
	"reflect"
	"regexp"
	"runtime"
	rundebug "runtime/debug"
	"sort"
	"strconv"
	"strings"
	"time"
	"github.com/gravitational/trace/internal"
	log "github.com/sirupsen/logrus"
	"golang.org/x/crypto/ssh/terminal"
)
const (
	FileField = "file"
	FunctionField = "func"
	LevelField = "level"
	Component = "trace.component"
	ComponentFields = "trace.fields"
	DefaultComponentPadding = 11
	DefaultLevelPadding = 4
)
func IsTerminal(w io.Writer) bool {
	switch v := w.(type) {
	case *os.File:
		return terminal.IsTerminal(int(v.Fd()))
	default:
		return false
	}
}
type TextFormatter struct {
	DisableTimestamp bool
	ComponentPadding int
	EnableColors bool
	FormatCaller func() (caller string)
}