refactor(logger): standardize logger format across codebase#3344
Merged
Conversation
- 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
…trics, 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)
- 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)
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #3344 +/- ##
===========================================
+ Coverage 46.76% 52.45% +5.69%
===========================================
Files 295 492 +197
Lines 17172 37790 +20618
===========================================
+ Hits 8031 19824 +11793
- Misses 8287 16365 +8078
- Partials 854 1601 +747 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Alanxtl
reviewed
May 27, 2026
…port, Dubbo, and Triple protocol modules
|
Alanxtl
approved these changes
May 28, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Fixes #3295
Summary
Standardize logger format across the dubbo-go codebase following a unified
convention. All logger calls are updated with consistent module prefixes,
unified key=value formatting, lowercase message bodies, and several
long-standing logger API misuses are fixed.
Changes
Prefix Convention
Every logger call now includes a
[Module][SubModule]CamelCase prefix:[GracefulShutdown][Internal][Metadata],[MetadataRPC][MetadataReport][Etcd][MetadataReport][Nacos][MetadataReport][Zookeeper][Metrics][Metrics][Probe][Metrics][Prometheus][Metrics][RPC][OTel][Trace][Protocol][Dubbo],[Dubbo][Codec/Hessian2/Impl/Exporter/Invoker][Dubbo3][GRPC],[GRPC][Client/Server/Exporter/Invoker][Jsonrpc],[Jsonrpc][Server/Exporter/Invoker][Rest],[Rest][Config/Exporter/Server][Triple],[Triple][Client/Server/Exporter/Invoker/CORS/Codec/Handler/Negotiation/Protocol/Health/OpenAPI]Key Format Unification
error: %v/err: %v/error:{%v}/: %v→err=%vurl: %s→url=%srevision: %s→revision=%skey=%vformat separated by,Message Body
---)%+vformat specifiers for non-Debug levelsBug Fixes
logger.Error(err)whereerris anerrortype →logger.Errorf("...err=%v", err)(dubbo_codec.go, dubbo_protocol.go, exporter.go ×2)
logger.Error("msg", extraArg)where extraArg was silently dropped →logger.Errorf("msg %s", extraArg)(rpc_status.go ×3, listener.go, server.go)logger.Errorf(formatErr.Error())with no format args →logger.Error("[Module] " + formatErr.Error())(metadata_service.go)logger.Infof/Debugfwithout format args →logger.Info/Debug(config.go ×2, report.go, triple.go ×3, etc.)
err.Error()+%s→err+%v(nacos/report.go ×2, dubbo3_protocol.go)Checklist
develop