瀏覽代碼

fix(logx): display garbled characters in windows(DOS, Powershell) (#2232)

* fix(logx): display garbled characters in windows(DOS, Powershell)

* Update writer.go
chen quan 2 年之前
父節點
當前提交
847a396f1c
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      core/logx/writer.go

+ 3 - 3
core/logx/writer.go

@@ -5,12 +5,12 @@ import (
 	"fmt"
 	"io"
 	"log"
-	"os"
 	"path"
 	"strings"
 	"sync"
 	"sync/atomic"
 
+	fatihcolor "github.com/fatih/color"
 	"github.com/zeromicro/go-zero/core/color"
 )
 
@@ -76,8 +76,8 @@ func (w *atomicWriter) Swap(v Writer) Writer {
 }
 
 func newConsoleWriter() Writer {
-	outLog := newLogWriter(log.New(os.Stdout, "", flags))
-	errLog := newLogWriter(log.New(os.Stderr, "", flags))
+	outLog := newLogWriter(log.New(fatihcolor.Output, "", flags))
+	errLog := newLogWriter(log.New(fatihcolor.Error, "", flags))
 	return &concreteWriter{
 		infoLog:   outLog,
 		errorLog:  errLog,