mirror of https://github.com/sirupsen/logrus.git
Added support for text coloring on Windows 10
This commit is contained in:
parent
778f2e774c
commit
bb487e068c
|
@ -67,6 +67,8 @@ type TextFormatter struct {
|
||||||
func (f *TextFormatter) init(entry *Entry) {
|
func (f *TextFormatter) init(entry *Entry) {
|
||||||
if entry.Logger != nil {
|
if entry.Logger != nil {
|
||||||
f.isTerminal = checkIfTerminal(entry.Logger.Out)
|
f.isTerminal = checkIfTerminal(entry.Logger.Out)
|
||||||
|
|
||||||
|
f.initTerminal(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
// +build !appengine,!gopherjs
|
||||||
|
|
||||||
|
package logrus
|
||||||
|
|
||||||
|
func (f *TextFormatter) initTerminal(entry *Entry) {
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
// +build !appengine,!gopherjs
|
||||||
|
|
||||||
|
package logrus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
sequences "github.com/konsorten/go-windows-terminal-sequences"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (f *TextFormatter) initTerminal(entry *Entry) {
|
||||||
|
switch v := entry.Logger.Out.(type) {
|
||||||
|
case *os.File:
|
||||||
|
handle := syscall.Handle(v.Fd())
|
||||||
|
|
||||||
|
sequences.EnableVirtualTerminalProcessing(handle, true)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue