Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg, tools: improve the log message #1636

Merged
merged 3 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
3 changes: 1 addition & 2 deletions pkg/etcdutil/etcdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package etcdutil
import (
"context"
"crypto/tls"
"fmt"
"net/http"
"time"

Expand Down Expand Up @@ -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
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/tempurl/tempurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"time"

log "github.com/pingcap/log"
"go.uber.org/zap"
)

var (
Expand All @@ -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()
Expand Down
7 changes: 3 additions & 4 deletions server/api/redirector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package api

import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -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
}

Expand Down
14 changes: 11 additions & 3 deletions server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tools/pd-tso-bench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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))
}
}

Expand Down