cockroachdb / cockroachdb/cockroach
raft: `raftlogger` and `rafttest` should use `pkg/util/log` instead of stdlib `log` package
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
This lint failure was uncovered when #132258 was addressed:
```
github.com/cockroachdb/cockroach/pkg/raft/raftlogger: log <- please use "util/log" instead of "log"
```
Attempting to follow this advice results in the following:
```
pkg/raft/raftlogger/logger.go:63:49: undefined: log.New
pkg/raft/raftlogger/logger.go:63:76: undefined: log.LstdFlags
pkg/raft/raftlogger/logger.go:64:49: undefined: log.New
pkg/raft/raftlogger/logger.go:75:7: undefined: log.Logger
pkg/raft/raftlogger/logger.go:89:5: l.Output undefined (type *DefaultLogger has no field or method Output)
pkg/raft/raftlogger/logger.go:95:5: l.Output undefined (type *DefaultLogger has no field or method Output)
pkg/raft/raftlogger/logger.go:108:4: l.Output undefined (type *DefaultLogger has no field or method Output)
pkg/raft/raftlogger/logger.go:112:4: l.Output undefined (type *DefaultLogger has no field or method Output)
pkg/raft/raftlogger/logger.go:124:4: l.Output undefined (type *DefaultLogger has no field or method Output)
pkg/raft/raftlogger/logger.go:129:4: l.Output undefined (type *DefaultLogger has no field or method Output)
pkg/raft/raftlogger/logger.go:129:4: too many errors
```
So some refactoring is necessary here.
For now we will exempt this in the lint check.
There is also an issue with `rafttest` (fails to find a function `log.Printf()`)
Jira issue: CRDB-42906
Contributor guide
Research direction
Start with pkg/raft/raftlogger/logger.go and inspect how its stdlib log.Logger, log.New, log.LstdFlags, and Output calls map to pkg/util/log. Then inspect rafttest for its log.Printf usage and the lint exemption added for these packages. Done means both packages use pkg/util/log, compile without the reported errors, and no longer require the lint exemption.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- distributed-systems
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100