mirror of
https://github.com/minio/minio.git
synced 2025-04-27 13:24:52 -04:00
Fix Windows console printing (#8805)
Print to console which does translation and not directly to stdout. Fixes #8804
This commit is contained in:
parent
3320878dfb
commit
627fdfeab7
@ -119,16 +119,16 @@ func (f fatalMsg) pretty(msg string, args ...interface{}) {
|
|||||||
ansiSaveAttributes()
|
ansiSaveAttributes()
|
||||||
// Print banner with or without the log tag
|
// Print banner with or without the log tag
|
||||||
if !tagPrinted {
|
if !tagPrinted {
|
||||||
fmt.Print(logBanner)
|
c.Print(logBanner)
|
||||||
tagPrinted = true
|
tagPrinted = true
|
||||||
} else {
|
} else {
|
||||||
fmt.Print(emptyBanner)
|
c.Print(emptyBanner)
|
||||||
}
|
}
|
||||||
// Restore the text color of the error message
|
// Restore the text color of the error message
|
||||||
ansiRestoreAttributes()
|
ansiRestoreAttributes()
|
||||||
ansiMoveRight(bannerWidth)
|
ansiMoveRight(bannerWidth)
|
||||||
// Continue error message printing
|
// Continue error message printing
|
||||||
fmt.Println(line)
|
c.Println(line)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
"github.com/minio/minio/cmd/logger"
|
"github.com/minio/minio/cmd/logger"
|
||||||
"github.com/minio/minio/cmd/logger/message/log"
|
"github.com/minio/minio/cmd/logger/message/log"
|
||||||
"github.com/minio/minio/pkg/color"
|
"github.com/minio/minio/pkg/color"
|
||||||
|
"github.com/minio/minio/pkg/console"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Target implements loggerTarget to send log
|
// Target implements loggerTarget to send log
|
||||||
@ -109,7 +110,7 @@ func (c *Target) Send(e interface{}, logKind string) error {
|
|||||||
apiString, timeString, deploymentID, requestID, remoteHost, host, userAgent,
|
apiString, timeString, deploymentID, requestID, remoteHost, host, userAgent,
|
||||||
msg, tagString, strings.Join(trace, "\n"))
|
msg, tagString, strings.Join(trace, "\n"))
|
||||||
|
|
||||||
fmt.Println(output)
|
console.Println(output)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ package logger
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/minio/minio/pkg/color"
|
"github.com/minio/minio/pkg/color"
|
||||||
)
|
)
|
||||||
@ -32,18 +33,27 @@ func ansiEscape(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ansiMoveRight(n int) {
|
func ansiMoveRight(n int) {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return
|
||||||
|
}
|
||||||
if color.IsTerminal() {
|
if color.IsTerminal() {
|
||||||
ansiEscape("[%dC", n)
|
ansiEscape("[%dC", n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ansiSaveAttributes() {
|
func ansiSaveAttributes() {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return
|
||||||
|
}
|
||||||
if color.IsTerminal() {
|
if color.IsTerminal() {
|
||||||
ansiEscape("7")
|
ansiEscape("7")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ansiRestoreAttributes() {
|
func ansiRestoreAttributes() {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return
|
||||||
|
}
|
||||||
if color.IsTerminal() {
|
if color.IsTerminal() {
|
||||||
ansiEscape("8")
|
ansiEscape("8")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user