You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/08/28 15:10:17 UTC

[GitHub] [dubbo-go] cjphaha opened a new pull request #1419: Ftr: add config enhance logger

cjphaha opened a new pull request #1419:
URL: https://github.com/apache/dubbo-go/pull/1419


   * delete the init func in common/logger.go
   * merge conflit
   * add lumberjack config to config/logger_config.go
   * set the logger module as the first one when loaded the config in config/root_config.go


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] zhaoyunxing92 merged pull request #1419: Ftr: add config enhance logger

Posted by GitBox <gi...@apache.org>.
zhaoyunxing92 merged pull request #1419:
URL: https://github.com/apache/dubbo-go/pull/1419


   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] zhaoyunxing92 commented on a change in pull request #1419: Ftr: add config enhance logger

Posted by GitBox <gi...@apache.org>.
zhaoyunxing92 commented on a change in pull request #1419:
URL: https://github.com/apache/dubbo-go/pull/1419#discussion_r697883325



##########
File path: config/testdata/config/logger/log.yml
##########
@@ -0,0 +1,36 @@
+dubbo:
+  registries:
+    nacos:
+      timeout: 5s
+      group: dev
+      address: nacos://127.0.0.1:8848
+    zk:
+      protocol: zookeeper
+      group: test
+      address: 127.0.0.1:2181
+  logger:
+    level: "debug"
+    development: false

Review comment:
       yaml配置里面不建议用引号

##########
File path: common/logger/logger_test.go
##########
@@ -19,32 +19,65 @@ package logger
 
 import (
 	"fmt"
+	"io/ioutil"
+	"path"
 	"path/filepath"
 	"runtime"
 	"testing"
 )
 
 import (
+	perrors "github.com/pkg/errors"
 	"github.com/stretchr/testify/assert"
+	"gopkg.in/yaml.v2"
 )
 
+// initLog use for init logger by call InitLogger
+func initLog(logConfFile string) error {
+	if logConfFile == "" {
+		InitLogger(nil)
+		return perrors.New("log configure file name is nil")
+	}
+	if path.Ext(logConfFile) != ".yml" {
+		InitLogger(nil)
+		return perrors.Errorf("log configure file name{%s} suffix must be .yml", logConfFile)
+	}
+
+	confFileStream, err := ioutil.ReadFile(logConfFile)
+	if err != nil {

Review comment:
       测试用例可以参考已有的[test](https://github.com/apache/dubbo-go/tree/config-enhance/config/testdata/config)

##########
File path: config/logger_config.go
##########
@@ -17,10 +17,86 @@
 
 package config
 
+import (
+	"net/url"
+)
+
+import (
+	"github.com/creasty/defaults"
+	"github.com/natefinch/lumberjack"
+)
+
+import (
+	"dubbo.apache.org/dubbo-go/v3/common/logger"
+	"dubbo.apache.org/dubbo-go/v3/common/yaml"
+)
+
+type ZapConfig struct {
+	Level             string                 `default:"debug" json:"level" yaml:"level" property:"level"`
+	Development       bool                   `default:"false" json:"development" yaml:"development" property:"development"`
+	DisableCaller     bool                   `default:"false" json:"disable_caller" yaml:"disable_caller" property:"disable_caller"`
+	DisableStacktrace bool                   `default:"false" json:"disable_stacktrace" yaml:"disable_stacktrace" property:"disable_stacktrace"`
+	Encoding          string                 `default:"console" json:"encoding" yaml:"encoding" property:"encoding"`
+	EncoderConfig     EncoderConfig          `default:"" json:"encoder_config" yaml:"encoder_config" property:"encoder_config"`
+	OutputPaths       []string               `default:"[\"stderr\"]" json:"output_paths" yaml:"output_paths" property:"output_paths"`
+	ErrorOutputPaths  []string               `default:"[\"stderr\"]" json:"error_output_paths" yaml:"error_output_paths" property:"error_output_paths"`
+	InitialFields     map[string]interface{} `default:"" json:"initial_fields" yaml:"initial_fields" property:"initial_fields"`
+}
+
 type LoggerConfig struct {
+	LumberjackConfig *lumberjack.Logger `yaml:"lumberjackConfig"`
+	ZapConfig        ZapConfig          `yaml:"zapConfig"`
+}
+
+type EncoderConfig struct {
+	MessageKey     string            `default:"message" json:"message_key" yaml:"message_key" property:"message_key"`
+	LevelKey       string            `default:"level" json:"level_key" yaml:"level_key" property:"level_key"`
+	TimeKey        string            `default:"time" json:"time_key" yaml:"time_key" property:"time_key"`
+	NameKey        string            `default:"logger" json:"name_key" yaml:"name_key" property:"name_key"`

Review comment:
       这些下划线改横线,getUrlMap方法返回值考虑下dubbo url




-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] cjphaha commented on pull request #1419: Ftr: add config enhance logger

Posted by GitBox <gi...@apache.org>.
cjphaha commented on pull request #1419:
URL: https://github.com/apache/dubbo-go/pull/1419#issuecomment-907744441


    @zhaoyunxing92  谢谢 review,新的 commit 修复了上面的问题
   
   * 统一使用 ;-' 来替代 '_'
   * 移除 common/logger 里面的单测
   * 移除 yaml 中的双引号


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org