forked from mirror/logrus
Unified terminal initialization code handling
This commit is contained in:
parent
9bc59a5969
commit
2f58bc83cb
|
@ -3,11 +3,15 @@
|
|||
|
||||
package logrus
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
import (
|
||||
"io"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const ioctlReadTermios = unix.TIOCGETA
|
||||
|
||||
type Termios unix.Termios
|
||||
|
||||
func (f *TextFormatter) initTerminal(entry *Entry) {
|
||||
func initTerminal(w io.Writer) {
|
||||
}
|
||||
|
|
|
@ -7,11 +7,15 @@
|
|||
|
||||
package logrus
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
import (
|
||||
"io"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const ioctlReadTermios = unix.TCGETS
|
||||
|
||||
type Termios unix.Termios
|
||||
|
||||
func (f *TextFormatter) initTerminal(entry *Entry) {
|
||||
func initTerminal(w io.Writer) {
|
||||
}
|
||||
|
|
|
@ -3,17 +3,16 @@
|
|||
package logrus
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
sequences "github.com/konsorten/go-windows-terminal-sequences"
|
||||
)
|
||||
|
||||
func (f *TextFormatter) initTerminal(entry *Entry) {
|
||||
switch v := entry.Logger.Out.(type) {
|
||||
func initTerminal(w io.Writer) {
|
||||
switch v := w.(type) {
|
||||
case *os.File:
|
||||
handle := syscall.Handle(v.Fd())
|
||||
|
||||
sequences.EnableVirtualTerminalProcessing(handle, true)
|
||||
sequences.EnableVirtualTerminalProcessing(syscall.Handle(v.Fd()), true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ func (f *TextFormatter) init(entry *Entry) {
|
|||
f.isTerminal = checkIfTerminal(entry.Logger.Out)
|
||||
|
||||
if f.isTerminal {
|
||||
f.initTerminal(entry)
|
||||
initTerminal(entry.Logger.Out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue