diff --git a/bench/main.go b/bench/main.go index 11d49b9..028e3a8 100644 --- a/bench/main.go +++ b/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() diff --git a/dtmcli/logger/log.go b/dtmcli/logger/log.go index 0ad6e9f..6ba0614 100644 --- a/dtmcli/logger/log.go +++ b/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 { diff --git a/dtmsvr/config/config.go b/dtmsvr/config/config.go index 848cabb..4cc8dda 100644 --- a/dtmsvr/config/config.go +++ b/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 diff --git a/dtmsvr/svr.go b/dtmsvr/svr.go index 5a9ca89..0f4ee75 100644 --- a/dtmsvr/svr.go +++ b/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 {