Enforce log.WithError(err) static analysis and fix all violations (#11163)

* Use log.WithError static analysis from #11143 and fix all violations

* Fix another log violation after pulling from develop

* Update beacon-chain/sync/pending_blocks_queue.go

Co-authored-by: Potuz <potuz@prysmaticlabs.com>

* @potuz feedback

* Copy paste fail

* fix tests

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Potuz <potuz@prysmaticlabs.com>
This commit is contained in:
Preston Van Loon
2022-08-05 05:52:02 -05:00
committed by GitHub
parent 1323912625
commit 9d375969d1
61 changed files with 193 additions and 175 deletions

View File

@@ -141,7 +141,7 @@ func (h *HandlerT) StartCPUProfile(file string) error {
}
if err := pprof.StartCPUProfile(f); err != nil {
if err := f.Close(); err != nil {
log.Errorf("Failed to close file: %v", err)
log.WithError(err).Error("Failed to close file")
}
return err
}
@@ -191,7 +191,7 @@ func (h *HandlerT) StartGoTrace(file string) error {
}
if err := trace.Start(f); err != nil {
if err := f.Close(); err != nil {
log.Errorf("Failed to close file: %v", err)
log.WithError(err).Error("Failed to close file")
}
return err
}
@@ -270,7 +270,7 @@ func (*HandlerT) WriteMemProfile(file string) error {
func (*HandlerT) Stacks() string {
buf := new(bytes.Buffer)
if err := pprof.Lookup("goroutine").WriteTo(buf, 2); err != nil {
log.Errorf("Failed to write pprof goroutine stacks: %v", err)
log.WithError(err).Error("Failed to write pprof goroutine stacks")
}
return buf.String()
}
@@ -365,12 +365,12 @@ func startPProf(address string) {
func Exit(ctx *cli.Context) {
if traceFile := ctx.String(TraceFlag.Name); traceFile != "" {
if err := Handler.StopGoTrace(); err != nil {
log.Errorf("Failed to stop go tracing: %v", err)
log.WithError(err).Error("Failed to stop go tracing")
}
}
if cpuFile := ctx.String(CPUProfileFlag.Name); cpuFile != "" {
if err := Handler.StopCPUProfile(); err != nil {
log.Errorf("Failed to stop CPU profiling: %v", err)
log.WithError(err).Error("Failed to stop CPU profiling")
}
}
}

View File

@@ -98,7 +98,7 @@ func meetsMinPlatformReqs(ctx context.Context) (bool, error) {
func WarnIfPlatformNotSupported(ctx context.Context) {
supported, err := meetsMinPlatformReqs(ctx)
if err != nil {
log.Warnf("Failed to detect host platform: %v", err)
log.WithError(err).Warn("Failed to detect host platform")
return
}
if !supported {