Skip to content

Commit

Permalink
*: add pingcap/log encoder as the default encoder (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhebox authored Aug 31, 2022
1 parent 8915c07 commit b49db9a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/weirproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func main() {

zapcfg := zap.NewDevelopmentConfig()
zapcfg.Encoding = cfg.Log.Encoder
zapcfg.DisableStacktrace = true
if level, err := zap.ParseAtomicLevel(cfg.Log.Level); err == nil {
zapcfg.Level = level
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/util/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sync"
"syscall"

"github.com/pingcap/log"
"github.com/spf13/cobra"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand All @@ -32,6 +33,9 @@ var registerEncoders sync.Once
func RunRootCommand(rootCmd *cobra.Command) {
registerEncoders.Do(func() {
zap.RegisterEncoder("tidb", func(cfg zapcore.EncoderConfig) (zapcore.Encoder, error) {
return log.NewTextEncoder(&log.Config{})
})
zap.RegisterEncoder("newtidb", func(cfg zapcore.EncoderConfig) (zapcore.Encoder, error) {
return NewTiDBEncoder(cfg), nil
})
})
Expand Down

0 comments on commit b49db9a

Please sign in to comment.