Skip to content

Commit

Permalink
fix a bug of terminal log printing
Browse files Browse the repository at this point in the history
Fprint should be Fprintf
  • Loading branch information
iotdog authored Dec 22, 2020
1 parent d5cb050 commit 2c81d49
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions log/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func CPrintf(color []byte, format string, args ...interface{}) {
func CPrintfln(color []byte, format string, args ...interface{}) {
logStr := fmt.Sprintf(format, args...)
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Fprint(os.Stdout, string(color)+funcFileLine()+"%s"+string(reset)+"\n", logStr)
fmt.Fprintf(os.Stdout, string(color)+funcFileLine()+"%s"+string(reset)+"\n", logStr)
} else {
fmt.Fprintf(os.Stdout, "%s\n", logStr)
}
Expand All @@ -85,7 +85,7 @@ func CPrintfln(color []byte, format string, args ...interface{}) {
func CEPrintf(color []byte, format string, args ...interface{}) {
logStr := fmt.Sprintf(format, args...)
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Fprint(os.Stderr, string(color)+funcFileLine()+"%s"+string(reset), logStr)
fmt.Fprintf(os.Stderr, string(color)+funcFileLine()+"%s"+string(reset), logStr)
} else {
fmt.Fprintf(os.Stderr, "%s", logStr)
}
Expand All @@ -94,7 +94,7 @@ func CEPrintf(color []byte, format string, args ...interface{}) {
func CEPrintfln(color []byte, format string, args ...interface{}) {
logStr := fmt.Sprintf(format, args...)
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Fprint(os.Stderr, string(color)+funcFileLine()+"%s"+string(reset)+"\n", logStr)
fmt.Fprintf(os.Stderr, string(color)+funcFileLine()+"%s"+string(reset)+"\n", logStr)
} else {
fmt.Fprintf(os.Stderr, "%s\n", logStr)
}
Expand Down

0 comments on commit 2c81d49

Please sign in to comment.