Qiao-yq opened a new pull request, #3344:
URL: https://github.com/apache/dubbo-go/pull/3344
### 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:
| Module | Prefix |
|--------|--------|
| graceful_shutdown | `[GracefulShutdown]` |
| internal | `[Internal]` |
| metadata | `[Metadata]`, `[MetadataRPC]` |
| metadata/report/etcd | `[MetadataReport][Etcd]` |
| metadata/report/nacos | `[MetadataReport][Nacos]` |
| metadata/report/zookeeper | `[MetadataReport][Zookeeper]` |
| metrics | `[Metrics]` |
| metrics/probe | `[Metrics][Probe]` |
| metrics/prometheus | `[Metrics][Prometheus]` |
| metrics/rpc | `[Metrics][RPC]` |
| otel/trace | `[OTel][Trace]` |
| protocol/base | `[Protocol]` |
| protocol/dubbo | `[Dubbo]`,
`[Dubbo][Codec/Hessian2/Impl/Exporter/Invoker]` |
| protocol/dubbo3 | `[Dubbo3]` |
| protocol/grpc | `[GRPC]`, `[GRPC][Client/Server/Exporter/Invoker]` |
| protocol/jsonrpc | `[Jsonrpc]`, `[Jsonrpc][Server/Exporter/Invoker]` |
| protocol/rest | `[Rest]`, `[Rest][Config/Exporter/Server]` |
| protocol/triple | `[Triple]`,
`[Triple][Client/Server/Exporter/Invoker/CORS/Codec/Handler/Negotiation/Protocol/Health/OpenAPI]`
|
### Key Format Unification
- `error: %v` / `err: %v` / `error:{%v}` / `: %v` → `err=%v`
- `url: %s` → `url=%s`
- `revision: %s` → `revision=%s`
- All keys use `key=%v` format separated by `, `
### Message Body
- All message body first letters changed to lowercase (except proper nouns)
- Removed decoration symbols (`---`)
- Removed `%+v` format specifiers for non-Debug levels
### Bug Fixes
- `logger.Error(err)` where `err` is an `error` type →
`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/Debugf` without 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
- [x] I confirm the target branch is `develop`
- [x] Code has passed local testing
- [x] I have added tests that prove my fix is effective or that my feature
works
--
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]