Skip to content

fix(logger): sync dubbo-go logger facade during logger initialization#3345

Merged
Alanxtl merged 5 commits into
apache:developfrom
XnLemon:fix/synclogger
May 27, 2026
Merged

fix(logger): sync dubbo-go logger facade during logger initialization#3345
Alanxtl merged 5 commits into
apache:developfrom
XnLemon:fix/synclogger

Conversation

@XnLemon
Copy link
Copy Markdown

@XnLemon XnLemon commented May 27, 2026

Description

Fixes #3339

在 logger 初始化阶段,dubbo-go 自身的 loggerfacade(dubbo.apache.org/dubbo-go/v3/logger)从未被同步设置。初始化代码只调用了 github.com/dubbogo/gost/log/logger.SetLogger()getty.SetLogger(),导致 facade 内部的全局变量始终为 nil
用户调用 dubboLogger.SetLoggerLevel() 时,facade 对 nil 做类型断言,静默返回 false ,日志级别调整完全不生效。

修复内容:

  • fix(logger): sync dubbo-go logger facade in LoggerConfig.Init()
    修复 config/logger_config.goInit() 方法,在设置 gost logger 和 getty 的同时,同步设置 dubbo-go
    facade。同时为两个 logger 包的 import 添加明确的 alias(gostLogger / dubboLogger)避免包名歧义。

  • fix(logger): sync dubbo-go logger facade in config_loader init()
    修复 config/config_loader.goinit() 函数,程序启动时的默认 zap logger 同步设置到 dubbo-go
    facade。

  • fix(logger): sync dubbo-go logger facade in initGlobalLogger()
    修复 instance_options_init.goinitGlobalLogger() 方法,dubbo.NewInstance() 初始化路径下同步设置
    dubbo-go facade。

  • test(logger): verify dubbo-go facade is synced after logger initialization
    新增测试覆盖:zap driver、logrus driver、zap + trace-integration 三条路径,验证 facade 初始化后不为
    nil,且 SetLoggerLevel 在 zap driver 下能正确生效(包括开启 trace-integration 时通过 ZapCtxLogger
    wrapper 的透传)。

Btw:
第一次提pr,辛苦reviewer了owo

Checklist

  • I confirm the target branch is develop
  • Code has passed local testing
  • I have added tests that prove my fix is effective or that my feature works

@sonarqubecloud
Copy link
Copy Markdown

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.38095% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.45%. Comparing base (60d1c2a) to head (6612623).
⚠️ Report is 807 commits behind head on develop.

Files with missing lines Patch % Lines
instance_options_init.go 37.50% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3345      +/-   ##
===========================================
+ Coverage    46.76%   52.45%   +5.68%     
===========================================
  Files          295      492     +197     
  Lines        17172    37793   +20621     
===========================================
+ Hits          8031    19825   +11794     
- Misses        8287    16367    +8080     
- Partials       854     1601     +747     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Alanxtl
Copy link
Copy Markdown
Contributor

Alanxtl commented May 27, 2026

cool work 下次记得在issue里面先留言,这样我就可以直接assign给你了,要不有可能和别人干重复

Copy link
Copy Markdown
Contributor

@Alanxtl Alanxtl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Alanxtl Alanxtl merged commit 8047928 into apache:develop May 27, 2026
8 checks passed
@XnLemon
Copy link
Copy Markdown
Author

XnLemon commented May 27, 2026

okok下次会记得的!-w-

cool work 下次记得在issue里面先留言,这样我就可以直接assign给你了,要不有可能和别人干重复

Alanxtl pushed a commit that referenced this pull request May 30, 2026
…#3345)

* fix(logger): sync dubbo-go logger facade in LoggerConfig.Init()

* fix(logger): sync dubbo-go logger facade in config_loader init()

* fix(logger): sync dubbo-go logger facade in initGlobalLogger()

* test(logger): verify dubbo-go facade is synced after logger initialization

* style(logger): fix import formatting
Alanxtl pushed a commit that referenced this pull request May 31, 2026
* fix(config): remove legacy protocol timeout fallback (#3326)

* fix(config): remove legacy protocol timeout fallback

* fix(config): avoid default timeout allocation

* fix(config): preserve consumer timeout in reference config

* test(config): satisfy testifylint in reference timeout test

* fix(config): make protocol timeout default explicit

* fix(config): centralize consumer timeout default

* fix(config): keep consumer timeout default in global

* Fix(config center)apollo context path error (#3331)

* feat(test):Add TestGetAddressWithProtocolPrefixKeepsContext and find the error when user bring context path

* fix(apollo):Fix the test func(getAddressWithProtocolPrefix) fix(context_path):fix getAddressWithProtolPrefix didn't handle context path

* refator(config_center):cleanup-redundant-test

* fix(test):删除不应该存在的文件

* feat():恢复测试并添加多种case

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix:修复url.Path = /问题并添加边缘测试;修复原来的不符合gofmt格式以通过CI

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix(logger): sync dubbo-go logger facade during logger initialization (#3345)

* fix(logger): sync dubbo-go logger facade in LoggerConfig.Init()

* fix(logger): sync dubbo-go logger facade in config_loader init()

* fix(logger): sync dubbo-go logger facade in initGlobalLogger()

* test(logger): verify dubbo-go facade is synced after logger initialization

* style(logger): fix import formatting

* refactor(logger): standardize logger format across codebase (#3344)

* refactor(logger): standardize logger format in graceful_shutdown

- Add [GracefulShutdown] prefix to all logger calls
- Remove decoration symbols (---) from log messages
- Change key format from "error: %v" / "--- %v" to "err=%v"
- Lowercase first letter of all log message bodies

* refactor(logger): standardize logger format in internal, metadata, metrics, otel

- Add module prefixes: [Internal], [Metadata], [MetadataRPC], [MetadataReport][Etcd/Nacos/Zookeeper], [Metrics], [Metrics][Probe/Prometheus/RPC], [OTel][Trace]
- Unify key format: "error: %v" / ": %v" / "err: %s" → "err=%v", "url: %s" → "url=%s"
- Lowercase first letter of all log message bodies
- Fix bug: logger.Error with non-string or extra args → logger.Errorf (listener.go, server.go, exporter.go)
- Fix bug: logger.Errorf with no format args → logger.Error (metadata_service.go)
- Fix bug: logger.Infof/Debugf with no format args → logger.Info/Debug (config.go, report.go)
- Fix: err.Error() + %s → err + %v (nacos/report.go x2)

* refactor(logger): standardize logger format in protocol directory

- Unify prefixes as [Protocol], [Dubbo], [Dubbo][Codec/Hessian2/Impl/Exporter/Invoker], [Dubbo3], [GRPC], [GRPC][Client/Server/Exporter/Invoker], [Jsonrpc], [Jsonrpc][Server/Exporter/Invoker], [ProtocolWrapper], [Rest], [Rest][Config/Exporter/Server], [Triple], [Triple][Client/Server/Exporter/Invoker/CORS/Codec/Handler/Negotiation/Protocol/Health/OpenAPI]
- Unify key format: "error: %v" / ": %v" / "error:{%v}" → "err=%v", "err: %v" → "err=%v"
- Lowercase first letter of all log message bodies
- Remove %+v format for non-Debug levels
- Fix bug: logger.Error with error type → logger.Errorf (dubbo_codec.go, dubbo_protocol.go)
- Fix bug: logger.Error/Info with extra args → logger.Errorf/Infof (rpc_status.go, jsonrpc/server.go)
- Fix bug: logger.Infof/Debugf without format args → logger.Info/Debug (multiple files)
- Fix bug: logger.Debug without format args → logger.Debugf (openapi/service.go)
- Fix: err.Error() + %s → err + %v (dubbo3_protocol.go)

* refactor(logger):standardize logger prefixes in metadata, metadata-report, Dubbo, and Triple protocol modules

* refactor(logger): unify log format in proxy and registry packages

- Add consistent [Proxy]/[Registry]/[Registry][<impl>] prefix to all log messages
- Adopt key=value parameter style (err=%v, url=%s) for structured logging
- Remove redundant descriptions and normalize punctuation across 30 files

* refactor(logger): unify log format in remoting, server and loader modules

- Add consistent [Loader]/[Server]/[Getty]/[Zookeeper]/[Etcdv3] prefixes
- Adopt key=value parameter style (err=%v, url=%s) for structured logging
- Remove trailing punctuation and redundant wording across 21 files

* feat(tools): add loggercheck linter for log format consistency

Introduce a static analysis tool that enforces the standardized logger
conventions across the codebase:

- Rule 1: logger.Info with format verbs → use logger.Infof
- Rule 2: logger.Infof without format verbs → use logger.Info
- Rule 3: logger.Infof(fmt.Sprintf(...)) → redundant, flatten to Infof
- Rule 4: trailing \n / ... / ! in log messages → remove

Integrated into make lint as the logger-check target.

* refactor(logger): final touch, unfiy logger format in other places

* fix(tools): remove unused variables in loggercheck to pass golangci-lint

* refactor: revert (feat(tools): add loggercheck) and simplify registry log prefixes

Remove loggercheck tool and its Makefile integration. Use [Registry] instead of [Registry][Protocol]/[Registry][Exposed] in core registry files; add [Registry][Mock] for mock registry

* fix(logger): correct format verbs, variable names, and function calls

* refactor(logger):modify prefix format

---------

Co-authored-by: CAICAII <3360776475@qq.com>
Co-authored-by: Yuxuan Lv <3656828039@qq.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Nene7ko_ <141395478+XnLemon@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.3.2 version 3.3.2 ☢️ Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Sync dubbo-go logger with gost logger / dubbo-go logger 与 gost logger 状态不同步

3 participants