Browse Source

fix CI lint problem.

pull/189/head
tinatwang 4 years ago
parent
commit
04f2ec41e8
  1. 2
      bench/main.go
  2. 11
      dtmcli/logger/log.go
  3. 2
      dtmsvr/config/config.go
  4. 2
      dtmsvr/svr.go

2
bench/main.go

@ -38,7 +38,7 @@ func main() {
if len(conf.Log.Outputs) != 0 {
outputs = strings.Split(conf.Log.Outputs, "|")
}
logger.InitLog(conf.Log.Level, outputs, conf.Log.LogRotationEnable, conf.Log.LogRotationConfigJson)
logger.InitLog(conf.Log.Level, outputs, conf.Log.LogRotationEnable, conf.Log.LogRotationConfigJSON)
if busi.BusiConf.Driver != "" {
dtmcli.SetCurrentDBType(busi.BusiConf.Driver)
svr.PrepareBenchDB()

11
dtmcli/logger/log.go

@ -17,6 +17,7 @@ import (
var logger Logger
// DefaultLogOutput is the default configuration for log output.
const (
DefaultLogOutput = "default"
StdErrLogOutput = "stderr"
@ -78,7 +79,7 @@ func InitLog(level string, outputs []string, logRotationEnable int64, logRotateC
// setup log rotation
if logRotationEnable != 0 {
_ = setupLogRotation(outputs, logRotateConfigJSON)
setupLogRotation(outputs, logRotateConfigJSON)
}
config := loadConfig(level)
@ -97,7 +98,7 @@ func (lumberjackSink) Sync() error {
}
// setupLogRotation initializes log rotation for a single file path target.
func setupLogRotation(logOutputs []string, logRotateConfigJSON string) error {
func setupLogRotation(logOutputs []string, logRotateConfigJSON string) {
var lumberjackSink lumberjackSink
outputFilePaths := 0
for _, v := range logOutputs {
@ -110,11 +111,11 @@ func setupLogRotation(logOutputs []string, logRotateConfigJSON string) error {
}
// log rotation requires file target
if len(logOutputs) == 1 && outputFilePaths == 0 {
FatalIfError(fmt.Errorf("log outputs requires a single file path when LogRotationConfigJson is defined"))
FatalIfError(fmt.Errorf("log outputs requires a single file path when LogRotationConfigJSON is defined"))
}
// support max 1 file target for log rotation
if outputFilePaths > 1 {
FatalIfError(fmt.Errorf("log outputs requires a single file path when LogRotationConfigJson is defined"))
FatalIfError(fmt.Errorf("log outputs requires a single file path when LogRotationConfigJSON is defined"))
}
if err := json.Unmarshal([]byte(logRotateConfigJSON), &lumberjackSink); err != nil {
@ -132,7 +133,7 @@ func setupLogRotation(logOutputs []string, logRotateConfigJSON string) error {
return &lumberjackSink, nil
})
FatalIfError(err)
return nil
return
}
func loadConfig(logLevel string) zap.Config {

2
dtmsvr/config/config.go

@ -34,7 +34,7 @@ type Log struct {
Level string `yaml:"Level" default:"info"`
Outputs string `yaml:"Outputs" default:""`
LogRotationEnable int64 `yaml:"LogRotationEnable" default:"0"`
LogRotationConfigJson string `yaml:"LogRotationConfigJson" default:""`
LogRotationConfigJSON string `yaml:"LogRotationConfigJSON" default:""`
}
// Store defines storage relevant info

2
dtmsvr/svr.go

@ -31,7 +31,7 @@ func StartSvr() {
if len(conf.Log.Outputs) != 0 {
outputs = strings.Split(conf.Log.Outputs, "|")
}
logger.InitLog(conf.Log.Level, outputs, conf.Log.LogRotationEnable, conf.Log.LogRotationConfigJson)
logger.InitLog(conf.Log.Level, outputs, conf.Log.LogRotationEnable, conf.Log.LogRotationConfigJSON)
dtmcli.GetRestyClient().SetTimeout(time.Duration(conf.RequestTimeout) * time.Second)
dtmgrpc.AddUnaryInterceptor(func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {

Loading…
Cancel
Save