mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
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:
@@ -8,6 +8,7 @@ go_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//tools/unencrypted-keys-gen/keygen:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@in_gopkg_yaml_v2//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -7,10 +7,10 @@ package main
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/tools/unencrypted-keys-gen/keygen"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
@@ -32,18 +32,18 @@ func main() {
|
||||
|
||||
in, err := os.ReadFile(inFile) // #nosec G304
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to read file %s: %v", inFile, err)
|
||||
log.WithError(err).Fatalf("Failed to read file %s", inFile)
|
||||
}
|
||||
data := make(KeyPairs, 0)
|
||||
if err := yaml.UnmarshalStrict(in, &data); err != nil {
|
||||
log.Fatalf("Failed to unmarshal yaml: %v", err)
|
||||
log.WithError(err).Fatal("Failed to unmarshal yaml")
|
||||
}
|
||||
|
||||
out := &keygen.UnencryptedKeysContainer{}
|
||||
for _, key := range data {
|
||||
pk, err := hex.DecodeString(key.Priv[2:])
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to decode hex string %s: %v", key.Priv, err)
|
||||
log.WithError(err).Fatalf("Failed to decode hex string %s", key.Priv)
|
||||
}
|
||||
|
||||
out.Keys = append(out.Keys, &keygen.UnencryptedKeys{
|
||||
@@ -54,7 +54,7 @@ func main() {
|
||||
|
||||
outFile, err := os.Create(os.Args[2])
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create file at %s: %v", os.Args[2], err)
|
||||
log.WithError(err).Fatalf("Failed to create file at %s", os.Args[2])
|
||||
}
|
||||
cleanup := func() {
|
||||
if err := outFile.Close(); err != nil {
|
||||
@@ -65,7 +65,7 @@ func main() {
|
||||
if err := keygen.SaveUnencryptedKeysToFile(outFile, out); err != nil {
|
||||
// log.Fatalf will prevent defer from being called
|
||||
cleanup()
|
||||
log.Fatalf("Failed to save %v", err)
|
||||
log.WithError(err).Fatal("Failed to save")
|
||||
}
|
||||
log.Printf("Wrote %s\n", os.Args[2])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user