forked from mirror/logrus
Add option to force TextFormatter to use colors
This commit is contained in:
parent
f33bbddc25
commit
436d68deda
|
@ -18,12 +18,14 @@ const (
|
|||
)
|
||||
|
||||
type TextFormatter struct {
|
||||
// Set to true to bypass checking for a TTY before outputting colors.
|
||||
ForceColors bool
|
||||
}
|
||||
|
||||
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
||||
var serialized []byte
|
||||
|
||||
if ttyutils.IsTerminal(os.Stdout.Fd()) {
|
||||
if f.ForceColors || ttyutils.IsTerminal(os.Stdout.Fd()) {
|
||||
levelText := strings.ToUpper(entry.Data["level"].(string))[0:4]
|
||||
|
||||
levelColor := blue
|
||||
|
|
Loading…
Reference in New Issue