Skip to content

Commit

Permalink
tiny clean
Browse files Browse the repository at this point in the history
Signed-off-by: nolouch <[email protected]>
  • Loading branch information
nolouch committed Jan 30, 2019
1 parent 83727c2 commit 01bfc7c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
5 changes: 5 additions & 0 deletions cmd/pd-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func main() {
if err != nil {
log.S().Fatalf("initialize logger error: %s\n", fmt.Sprintf("%+v", err))
}
// Flushing any buffered log entries
defer func() {
log.S().Sync()
log.L().Sync()
}()

// The old logger
err = logutil.InitLogger(&cfg.Log)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/pingcap/errors v0.10.1 // indirect
github.com/pingcap/gofail v0.0.0-20181217135706-6a951c1e42c3
github.com/pingcap/kvproto v0.0.0-20181123124450-d48563486f61
github.com/pingcap/log v0.0.0-20190124162537-b03a2096ae88
github.com/pingcap/log v0.0.0-20190129103703-6afc545b8868
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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ github.com/pingcap/gofail v0.0.0-20181217135706-6a951c1e42c3 h1:04yuCf5NMvLU8rB2
github.com/pingcap/gofail v0.0.0-20181217135706-6a951c1e42c3/go.mod h1:DazNTg0PTldtpsQiT9I5tVJwV1onHMKBBgXzmJUlMns=
github.com/pingcap/kvproto v0.0.0-20181123124450-d48563486f61 h1:Yms1MiO/ezhE9ozwEOnlh/HrEFHX/r3fPCV6vNThGDM=
github.com/pingcap/kvproto v0.0.0-20181123124450-d48563486f61/go.mod h1:0gwbe1F2iBIjuQ9AH0DbQhL+Dpr5GofU8fgYyXk+ykk=
github.com/pingcap/log v0.0.0-20190124162537-b03a2096ae88 h1:44Uu74xgFR8G+PE71sSuTkuzWyfdKYFAuwzzOJIahig=
github.com/pingcap/log v0.0.0-20190124162537-b03a2096ae88/go.mod h1:xsfkWVaFVV5B8e1K9seWfyJWFrIhbtUTAD8NV1Pq3+w=
github.com/pingcap/log v0.0.0-20190129103703-6afc545b8868 h1:zkyIcjTiuRIOvhuPvbB1wsRFZH5aPqz/3o7p8uAdEzU=
github.com/pingcap/log v0.0.0-20190129103703-6afc545b8868/go.mod h1:xsfkWVaFVV5B8e1K9seWfyJWFrIhbtUTAD8NV1Pq3+w=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
Expand Down
8 changes: 4 additions & 4 deletions pkg/logutil/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/coreos/pkg/capnslog"
. "github.com/pingcap/check"
zap "github.com/pingcap/log"
zaplog "github.com/pingcap/log"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -70,7 +70,7 @@ func (s *testLogSuite) TestStringToLogFormatter(c *C) {

// TestLogging assure log format and log redirection works.
func (s *testLogSuite) TestLogging(c *C) {
conf := &zap.Config{Level: "warn", File: zap.FileLogConfig{}}
conf := &zaplog.Config{Level: "warn", File: zaplog.FileLogConfig{}}
c.Assert(InitLogger(conf), IsNil)

log.SetOutput(s.buf)
Expand All @@ -95,6 +95,6 @@ func (s *testLogSuite) TestLogging(c *C) {
}

func (s *testLogSuite) TestFileLog(c *C) {
c.Assert(InitFileLog(&zap.FileLogConfig{Filename: "/tmp"}), NotNil)
c.Assert(InitFileLog(&zap.FileLogConfig{Filename: "/tmp/test_file_log", MaxSize: 0}), IsNil)
c.Assert(InitFileLog(&zaplog.FileLogConfig{Filename: "/tmp"}), NotNil)
c.Assert(InitFileLog(&zaplog.FileLogConfig{Filename: "/tmp/test_file_log", MaxSize: 0}), IsNil)
}
5 changes: 2 additions & 3 deletions server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import (
"strings"
"time"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"

"github.com/BurntSushi/toml"
"github.com/coreos/go-semver/semver"
"github.com/pingcap/log"
Expand All @@ -36,6 +33,8 @@ import (
"github.com/pkg/errors"
"go.etcd.io/etcd/embed"
"go.etcd.io/etcd/pkg/transport"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

// Config is the pd server configuration.
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type Server struct {
lastSavedTime time.Time
// For async region heartbeat.
hbStreams *heartbeatStreams
// For the logger
// Zap logger
lg *zap.Logger
logSyncer zapcore.WriteSyncer
}
Expand Down

0 comments on commit 01bfc7c

Please sign in to comment.