Enable go vet printf-auditing our logger (#6421)
Explicitly inform go vet about the names of our logging methods which should be checked in the same way as fmt.Printf is. Although go vet can often find such functions on its own, it can't find these ones because log.Logger is an interface, not a struct. In addition, fix several format string mistakes caught by go vet.
This commit is contained in:
parent
65a60807cc
commit
6874d909f2
|
|
@ -20,6 +20,16 @@ linters-settings:
|
|||
gosimple:
|
||||
# S1029: Range over the string directly
|
||||
checks: ["all", "-S1029"]
|
||||
govet:
|
||||
settings:
|
||||
printf:
|
||||
funcs:
|
||||
- (github.com/letsencrypt/boulder/log.Logger).Errf
|
||||
- (github.com/letsencrypt/boulder/log.Logger).Warningf
|
||||
- (github.com/letsencrypt/boulder/log.Logger).Infof
|
||||
- (github.com/letsencrypt/boulder/log.Logger).Debugf
|
||||
- (github.com/letsencrypt/boulder/log.Logger).AuditInfof
|
||||
- (github.com/letsencrypt/boulder/log.Logger).AuditErrf
|
||||
staticcheck:
|
||||
# SA1019: Using a deprecated function, variable, constant or field
|
||||
# SA6003: Converting a string to a slice of runes before ranging over it
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/big"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -168,8 +169,8 @@ func (cu *crlUpdater) Run(ctx context.Context) error {
|
|||
// We only log, rather than return, so that the long-lived process can
|
||||
// continue and try again at the next tick.
|
||||
cu.log.AuditErrf(
|
||||
"Generating CRLs failed: number=[%d] err=[%s]",
|
||||
crl.Number(atTime), err)
|
||||
"Generating CRLs failed: number=[%s] err=[%s]",
|
||||
(*big.Int)(crl.Number(atTime)), err)
|
||||
}
|
||||
case <-ctx.Done():
|
||||
ticker.Stop()
|
||||
|
|
@ -202,7 +203,7 @@ func (cu *crlUpdater) Tick(ctx context.Context, atTime time.Time) (err error) {
|
|||
if err != nil {
|
||||
cu.log.AuditErrf(
|
||||
"Generating CRLs for issuer failed: number=[%d] issuer=[%s] err=[%s]",
|
||||
crl.Number(atTime), cu.issuers[id].Subject.CommonName, err)
|
||||
(*big.Int)(crl.Number(atTime)), cu.issuers[id].Subject.CommonName, err)
|
||||
errIssuers = append(errIssuers, cu.issuers[id].Subject.CommonName)
|
||||
}
|
||||
}
|
||||
|
|
@ -327,7 +328,7 @@ func (cu *crlUpdater) tickShard(ctx context.Context, atTime time.Time, issuerNam
|
|||
}
|
||||
|
||||
cu.log.Infof(
|
||||
"Queried SA for CRL shard: id=[%s] numEntries=[%s]",
|
||||
"Queried SA for CRL shard: id=[%s] numEntries=[%d]",
|
||||
crlID, len(crlEntries))
|
||||
|
||||
// Send the full list of CRL Entries to the CA.
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ import (
|
|||
|
||||
// A Logger logs messages with explicit priority levels. It is
|
||||
// implemented by a logging back-end as provided by New() or
|
||||
// NewMock().
|
||||
// NewMock(). Any additions to this interface with format strings should be
|
||||
// added to the govet configuration in .golangci.yml
|
||||
type Logger interface {
|
||||
Err(msg string)
|
||||
Errf(format string, a ...interface{})
|
||||
|
|
|
|||
Loading…
Reference in New Issue