Qiao-yq opened a new pull request, #3346:
URL: https://github.com/apache/dubbo-go/pull/3346

   ### Description
   Fixes #3295 
   ## Summary
   
   Enforce a unified logger format specification across the entire codebase and 
introduce a static analysis tool (`loggercheck`) to prevent regressions in CI.
   
   ## Changes
   
   ### Logger format standardization 
   
   All logger calls now follow a consistent structure:
   
   `[Prefix] message description, key1=value1, key2=value2`
   
   
   **Prefix rules:** every log line carries a module-level prefix (e.g. 
`[Registry]`, `[Remoting][Getty]`, `[Server]`). Multi-implementation packages 
use a two-level prefix that identifies both the parent module and the specific 
implementation (e.g. `[Registry][Etcdv3]`, `[Registry][Nacos]`).
   
   **Parameter style:** parameters after the message body use `key=value` pairs 
separated by `, ` (e.g. `err=%v`, `url=%s`, `service=%s`). Format verbs like 
`%+v` and `%#v` are replaced with `%v` outside Debug level.
   
   **Message style:** kept existing wording intact for search/alert 
compatibility; removed trailing punctuation (`...`, `!`, `\n`); forced 
lowercase first letter.
   
   **Bug fixes found during the sweep:**
   
   - `logger.Error` called with format args (should be `logger.Errorf`) — fixed 
in `base_configuration_listener.go`, `pool.go`, `directory.go`, `server.go`
   - `logger.*f(fmt.Sprintf(...))` double-formatting anti-pattern — fixed in 
`action.go`
   
   ### Static analysis tool (`tools/loggercheck`)
   
   A new lightweight linter modeled after `tools/variadicrpccheck`. It walks 
the AST and reports four categories of logger format violations:
   
   | # | Rule | Example |
   |---|------|---------|
   | 1 | Non-`f` method with `%` verbs + extra args | `logger.Error("err=%v", 
e)` → use `Errorf` |
   | 2 | `*f` method without format verbs | `logger.Infof("no args")` → use 
`Info` |
   | 3 | `*f(fmt.Sprintf(...))` wrapping | `logger.Infof(fmt.Sprintf(...))` → 
flatten |
   | 4 | Trailing decorators in messages | `\n`, `...`, `!` at end of message 
string |
   
   The tool is **guidance-only** — it always exits 0 and prints warnings to 
stdout. It will not fail CI builds, but serves as a persistent reminder to keep 
new code aligned with the format spec.
   
   Integrated into `make lint` and runs before golangci-lint.
   
   
   ### 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]

Reply via email to