Skip to content

Commit

Permalink
cluster: omit debug log from console output (#977)
Browse files Browse the repository at this point in the history
* cluster: omit debug log from stdout but print to audit log instead

* cluster: adjust log level for pd querying failure when display

* *: update go mods

Co-authored-by: Ti Prow Robot <71242396+ti-community-prow-bot@users.noreply.github.com>
  • Loading branch information
AstroProfundis and ti-chi-bot authored Dec 9, 2020
1 parent 250c47b commit 15151f1
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/playground/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/pingcap/tiup/pkg/cliutil/progress"
"io"
"io/ioutil"
"net/http"
Expand All @@ -37,6 +36,7 @@ import (
"github.com/fatih/color"
"github.com/pingcap/errors"
"github.com/pingcap/tiup/components/playground/instance"
"github.com/pingcap/tiup/pkg/cliutil/progress"
"github.com/pingcap/tiup/pkg/cluster/api"
"github.com/pingcap/tiup/pkg/environment"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ require (
github.com/xo/usql v0.7.8
go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738
go.uber.org/atomic v1.6.0
go.uber.org/zap v1.15.0
go.uber.org/zap v1.16.0
golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72
golang.org/x/mod v0.2.0
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,9 @@ go.uber.org/zap v1.12.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.uber.org/zap v1.14.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
go.uber.org/zap v1.15.0 h1:ZZCA22JRF2gQE5FoNmhmrf7jeJJ2uhqDUNRYKm8dvmM=
go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
go.uber.org/zap v1.16.0 h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM=
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ func (m *Manager) Display(clusterName string, opt operator.Options) error {
// Check if TiKV's label set correctly
pdClient := api.NewPDClient(pdList, 10*time.Second, tlsCfg)
if lbs, err := pdClient.GetLocationLabels(); err != nil {
color.Yellow("\nWARN: get location labels from pd failed: %v", err)
log.Debugf("get location labels from pd failed: %v", err)
} else if err := spec.CheckTiKVLabels(lbs, pdClient); err != nil {
color.Yellow("\nWARN: there is something wrong with TiKV labels, which may cause data losing:\n%v", err)
}
Expand Down Expand Up @@ -1592,7 +1592,7 @@ func (m *Manager) ScaleOut(
return nil
}

// DestroyTombstone destory and remove instances that is in tombstone state
// DestroyTombstone destroy and remove instances that is in tombstone state
func (m *Manager) DestroyTombstone(
clusterName string,
gOpt operator.Options,
Expand Down
2 changes: 1 addition & 1 deletion pkg/logger/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func DisableAuditLog() {
func newAuditLogCore() zapcore.Core {
auditBuffer = bytes.NewBufferString(strings.Join(os.Args, " ") + "\n")
encoder := zapcore.NewConsoleEncoder(zap.NewDevelopmentEncoderConfig())
return zapcore.NewCore(encoder, zapcore.Lock(zapcore.AddSync(auditBuffer)), zapcore.InfoLevel)
return zapcore.NewCore(encoder, zapcore.Lock(zapcore.AddSync(auditBuffer)), zapcore.DebugLevel)
}

// OutputAuditLogIfEnabled outputs audit log if enabled.
Expand Down
2 changes: 0 additions & 2 deletions pkg/logger/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ import (
)

// Debugf output the debug message to console
// Deprecated: Use zap.L().Debug() instead
func Debugf(format string, args ...interface{}) {
zap.L().Debug(fmt.Sprintf(format, args...))
_, _ = fmt.Fprintf(os.Stderr, format+"\n", args...)
}

// Infof output the log message to console
Expand Down

0 comments on commit 15151f1

Please sign in to comment.