AlexStocks commented on code in PR #765:
URL: https://github.com/apache/dubbo-go-pixiu/pull/765#discussion_r2394860297


##########
pkg/logger/logger.go:
##########
@@ -94,45 +107,56 @@ func InitLog(logConfFile string) error {
        return nil
 }
 
+// InitLogger initializes logger. Default is development-style (console, 
debug),
+// but we force stacktrace to Error+ only, and enable caller with our custom 
encoder.
+// If a config is supplied, we respect it and only normalize caller encoder 
and stacktrace threshold.
 func InitLogger(conf *zap.Config) {
-       var zapLoggerConfig zap.Config
+       var cfg zap.Config
+
        if conf == nil {
-               zapLoggerConfig = zap.NewDevelopmentConfig()
-               zapLoggerEncoderConfig := zapcore.EncoderConfig{
-                       TimeKey:        "time",
-                       LevelKey:       "level",
-                       NameKey:        "pixiuLogger",
-                       CallerKey:      "caller",
-                       MessageKey:     "message",
-                       StacktraceKey:  "stacktrace",
-                       EncodeLevel:    zapcore.CapitalColorLevelEncoder,
-                       EncodeTime:     zapcore.ISO8601TimeEncoder,
-                       EncodeDuration: zapcore.SecondsDurationEncoder,
-                       EncodeCaller:   PaddedCallerEncoder,
-                       // EncodeCaller:   zapcore.ShortCallerEncoder,
-               }
-               zapLoggerConfig.EncoderConfig = zapLoggerEncoderConfig
+               // Default: development style
+               cfg = zap.NewDevelopmentConfig()
+
+               // Normalize/override keys & encoders for consistent console 
output
+               cfg.EncoderConfig.TimeKey = "time"

Review Comment:
   原来的先生成一个变量的写法,我觉得更优雅



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to