Skip to content

Commit

Permalink
tiny clean
Browse files Browse the repository at this point in the history
Signed-off-by: nolouch <nolouch@gmail.com>
  • Loading branch information
nolouch committed Jan 30, 2019
1 parent 83727c2 commit 80c2cfa
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 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
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ 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
github.com/sirupsen/logrus v1.0.5
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.1
github.com/stretchr/objx v0.1.1 // indirect
github.com/syndtr/goleveldb v0.0.0-20180815032940-ae2bd5eed72d
github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 // indirect
github.com/unrolled/render v0.0.0-20171102162132-65450fb6b2d3
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ github.com/pingcap/kvproto v0.0.0-20181123124450-d48563486f61 h1:Yms1MiO/ezhE9oz
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 All @@ -125,6 +127,7 @@ github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3
github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
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 80c2cfa

Please sign in to comment.