diff --git a/go.mod b/go.mod index 3d81846c830..9cdc8fd34e1 100644 --- a/go.mod +++ b/go.mod @@ -28,10 +28,9 @@ require ( github.com/opentracing/opentracing-go v1.0.2 github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8 github.com/pingcap/errcode v0.0.0-20180921232412-a1a7271709d9 - github.com/pingcap/errors v0.10.1 // indirect github.com/pingcap/failpoint v0.0.0-20190512135322-30cc7431d99c github.com/pingcap/kvproto v0.0.0-20190516013202-4cf58ad90b6c - github.com/pingcap/log v0.0.0-20190214045112-b37da76f67a7 + github.com/pingcap/log v0.0.0-20190715063458-479153f07ebd github.com/pkg/errors v0.8.1 github.com/prometheus/client_golang v0.8.0 github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5 // indirect diff --git a/go.sum b/go.sum index 70635cfbc92..398ffcab422 100644 --- a/go.sum +++ b/go.sum @@ -104,14 +104,14 @@ github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8 h1:USx2/E1bX46VG32FI github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8/go.mod h1:B1+S9LNcuMyLH/4HMTViQOJevkGiik3wW2AN9zb2fNQ= github.com/pingcap/errcode v0.0.0-20180921232412-a1a7271709d9 h1:KH4f4Si9XK6/IW50HtoaiLIFHGkapOM6w83za47UYik= github.com/pingcap/errcode v0.0.0-20180921232412-a1a7271709d9/go.mod h1:4b2X8xSqxIroj/IZ9MX/VGZhAwc11wB9wRIzHvz6SeM= -github.com/pingcap/errors v0.10.1 h1:fGVuPMtwNcxbzQ3aoRyyi6kxvXKMkEsceP81f3b8wsk= -github.com/pingcap/errors v0.10.1/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pingcap/errors v0.11.0 h1:DCJQB8jrHbQ1VVlMFIrbj2ApScNNotVmkSNplu2yUt4= +github.com/pingcap/errors v0.11.0/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pingcap/failpoint v0.0.0-20190512135322-30cc7431d99c h1:hvQd3aOLKLF7xvRV6DzvPkKY4QXzfVbjU1BhW0d9yL8= github.com/pingcap/failpoint v0.0.0-20190512135322-30cc7431d99c/go.mod h1:DNS3Qg7bEDhU6EXNHF+XSv/PGznQaMJ5FWvctpm6pQI= github.com/pingcap/kvproto v0.0.0-20190516013202-4cf58ad90b6c h1:pY/MQQ5UajEHfSnQS8rFAM9gw9bBKzqBl414cdfhpRQ= github.com/pingcap/kvproto v0.0.0-20190516013202-4cf58ad90b6c/go.mod h1:QMdbTAXCHzzygQzqcG9uVUgU2fKeSN1GmfMiykdSzzY= -github.com/pingcap/log v0.0.0-20190214045112-b37da76f67a7 h1:kOHAMalwF69bJrtWrOdVaCSvZjLucrJhP4NQKIu6uM4= -github.com/pingcap/log v0.0.0-20190214045112-b37da76f67a7/go.mod h1:xsfkWVaFVV5B8e1K9seWfyJWFrIhbtUTAD8NV1Pq3+w= +github.com/pingcap/log v0.0.0-20190715063458-479153f07ebd h1:hWDol43WY5PGhsh3+8794bFHY1bPrmu6bTalpssCrGg= +github.com/pingcap/log v0.0.0-20190715063458-479153f07ebd/go.mod h1:WpHUKhNZ18v116SvGrmjkA9CBhYmuUTKL+p8JC9ANEw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/pkg/etcdutil/etcdutil.go b/pkg/etcdutil/etcdutil.go index f314fbb8e2c..58cce288e75 100644 --- a/pkg/etcdutil/etcdutil.go +++ b/pkg/etcdutil/etcdutil.go @@ -16,7 +16,6 @@ package etcdutil import ( "context" "crypto/tls" - "fmt" "net/http" "time" @@ -61,7 +60,7 @@ func CheckClusterID(localClusterID types.ID, um types.URLsMap, tlsConfig *tls.Co trp.CloseIdleConnections() if gerr != nil { // Do not return error, because other members may be not ready. - log.Error(fmt.Sprintf("%v", gerr)) + log.Error("failed to get cluster from remote", zap.Error(gerr)) continue } diff --git a/pkg/tempurl/tempurl.go b/pkg/tempurl/tempurl.go index 0073b67b3f4..9ec9ea50eb5 100644 --- a/pkg/tempurl/tempurl.go +++ b/pkg/tempurl/tempurl.go @@ -20,6 +20,7 @@ import ( "time" log "github.com/pingcap/log" + "go.uber.org/zap" ) var ( @@ -42,12 +43,12 @@ func Alloc() string { func tryAllocTestURL() string { l, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { - log.Fatal(fmt.Sprintf("%v", err)) + log.Fatal("listen failed", zap.Error(err)) } addr := fmt.Sprintf("http://%s", l.Addr()) err = l.Close() if err != nil { - log.Fatal(fmt.Sprintf("%v", err)) + log.Fatal("close failed", zap.Error(err)) } testAddrMutex.Lock() diff --git a/server/api/redirector.go b/server/api/redirector.go index f51afc005c4..911f48e58bc 100644 --- a/server/api/redirector.go +++ b/server/api/redirector.go @@ -14,7 +14,6 @@ package api import ( - "fmt" "io/ioutil" "net/http" "net/url" @@ -95,21 +94,21 @@ func (p *customReverseProxies) ServeHTTP(w http.ResponseWriter, r *http.Request) resp, err := p.client.Do(r) if err != nil { - log.Error(fmt.Sprintf("%+v", err)) + log.Error("request failed", zap.Error(err)) continue } b, err := ioutil.ReadAll(resp.Body) resp.Body.Close() if err != nil { - log.Error(fmt.Sprintf("%+v", err)) + log.Error("request failed", zap.Error(err)) continue } copyHeader(w.Header(), resp.Header) w.WriteHeader(resp.StatusCode) if _, err := w.Write(b); err != nil { - log.Error(fmt.Sprintf("%+v", err)) + log.Error("write failed", zap.Error(err)) continue } diff --git a/server/config.go b/server/config.go index e351134b7ee..f7ccb0fa681 100644 --- a/server/config.go +++ b/server/config.go @@ -198,9 +198,10 @@ const ( defaultLeaderPriorityCheckInterval = time.Minute - defaultUseRegionStorage = true - defaultStrictlyMatchLabel = false - defaultEnableGRPCGateway = true + defaultUseRegionStorage = true + defaultStrictlyMatchLabel = false + defaultEnableGRPCGateway = true + defaultDisableErrorVerbose = true ) func adjustString(v *string, defValue string) { @@ -422,6 +423,7 @@ func (c *Config) Adjust(meta *toml.MetaData) error { return err } + c.adjustLog(configMetaData.Child("log")) adjustDuration(&c.heartbeatStreamBindInterval, defaultHeartbeatStreamRebindInterval) adjustDuration(&c.LeaderPriorityCheckInterval, defaultLeaderPriorityCheckInterval) @@ -435,6 +437,12 @@ func (c *Config) Adjust(meta *toml.MetaData) error { return nil } +func (c *Config) adjustLog(meta *configMetaData) { + if !meta.IsDefined("disable-error-verbose") { + c.Log.DisableErrorVerbose = defaultDisableErrorVerbose + } +} + func (c *Config) clone() *Config { cfg := &Config{} *cfg = *c diff --git a/tools/pd-tso-bench/main.go b/tools/pd-tso-bench/main.go index 25de3549f4e..f2494faf8ec 100644 --- a/tools/pd-tso-bench/main.go +++ b/tools/pd-tso-bench/main.go @@ -26,6 +26,7 @@ import ( log "github.com/pingcap/log" pd "github.com/pingcap/pd/client" "github.com/pkg/errors" + "go.uber.org/zap" ) var ( @@ -55,7 +56,7 @@ func main() { for i := 0; i < *concurrency; i++ { _, _, err = pdCli.GetTS(ctx) if err != nil { - log.Fatal(fmt.Sprintf("%v", err)) + log.Fatal("get tso failed", zap.Error(err)) } }