Skip to content

Commit

Permalink
Logs improvements (#830)
Browse files Browse the repository at this point in the history
* apply log format changes to Warn level
* update dependencies
  • Loading branch information
emmanuelm41 committed Oct 12, 2021
1 parent 6a18ad8 commit 136181d
Show file tree
Hide file tree
Showing 21 changed files with 151 additions and 96 deletions.
4 changes: 2 additions & 2 deletions chain/boltdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (b *boltStore) Len() int {
return nil
})
if err != nil {
log.DefaultLogger().Warn("boltdb", "error getting length", "err", err)
log.DefaultLogger().Warnw("", "boltdb", "error getting length", "err", err)
}
return length
}
Expand Down Expand Up @@ -145,7 +145,7 @@ func (b *boltStore) Cursor(fn func(chain.Cursor)) {
return nil
})
if err != nil {
log.DefaultLogger().Warn("boltdb", "error getting cursor", "err", err)
log.DefaultLogger().Warnw("", "boltdb", "error getting cursor", "err", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion chain/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (c *Info) Hash() []byte {
_ = binary.Write(h, binary.BigEndian, c.GenesisTime)
buff, err := c.PublicKey.MarshalBinary()
if err != nil {
log.DefaultLogger().Warn("info", "failed to hash pubkey", "err", err)
log.DefaultLogger().Warnw("", "info", "failed to hash pubkey", "err", err)
}
_, _ = h.Write(buff)
_, _ = h.Write(c.GroupHash)
Expand Down
6 changes: 3 additions & 3 deletions client/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (c *watchAggregator) passiveWatch(ctx context.Context) <-chan Result {
defer c.subscriberLock.Unlock()

if c.cancelPassive != nil {
c.log.Warn("watch_aggregator", "only support one passive watch")
c.log.Warnw("", "watch_aggregator", "only support one passive watch")
return nil
}

Expand Down Expand Up @@ -167,7 +167,7 @@ func (c *watchAggregator) distribute(in <-chan Result, cancel context.CancelFunc
c.subscriberLock.Lock()
if len(c.subscribers) == 0 {
c.subscriberLock.Unlock()
c.log.Warn("watch_aggregator", "no subscribers to distribute results to")
c.log.Warnw("", "watch_aggregator", "no subscribers to distribute results to")
return
}
aCtx := c.subscribers[0].ctx
Expand All @@ -192,7 +192,7 @@ func (c *watchAggregator) distribute(in <-chan Result, cancel context.CancelFunc
select {
case s.c <- m:
default:
c.log.Warn("watch_aggregator", "dropped watch message to subscriber. full channel")
c.log.Warnw("", "watch_aggregator", "dropped watch message to subscriber. full channel")
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion client/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (g *grpcClient) translate(stream drand.Public_PublicRandStreamClient, out c
next, err := stream.Recv()
if err != nil || stream.Context().Err() != nil {
if stream.Context().Err() == nil {
g.l.Warn("grpc_client", "public rand stream", "err", err)
g.l.Warnw("", "grpc_client", "public rand stream", "err", err)
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion client/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (h *httpClient) FetchChainInfo(chainHash []byte) (*chain.Info, error) {
}

if chainHash == nil {
h.l.Warn("http_client", "instantiated without trustroot", "chainHash", hex.EncodeToString(chainInfo.Hash()))
h.l.Warnw("", "http_client", "instantiated without trustroot", "chainHash", hex.EncodeToString(chainInfo.Hash()))
}
if chainHash != nil && !bytes.Equal(chainInfo.Hash(), chainHash) {
err := fmt.Errorf("%s does not advertise the expected drand group (%x vs %x)", h.root, chainInfo.Hash(), chainHash)
Expand Down
6 changes: 3 additions & 3 deletions client/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (v *verifyingClient) Watch(ctx context.Context) <-chan Result {
defer close(outCh)
for r := range inCh {
if err := v.verify(ctx, info, asRandomData(r)); err != nil {
v.log.Warn("verifying_client", "skipping invalid watch round", "round", r.Round(), "err", err)
v.log.Warnw("", "verifying_client", "skipping invalid watch round", "round", r.Round(), "err", err)
continue
}
outCh <- r
Expand Down Expand Up @@ -135,7 +135,7 @@ func (v *verifyingClient) getTrustedPreviousSignature(ctx context.Context, round
var next Result
for trustRound < round-1 {
trustRound++
v.log.Warn("verifying_client", "loading round to verify", "round", trustRound)
v.log.Warnw("", "verifying_client", "loading round to verify", "round", trustRound)
next, err = v.indirectClient.Get(ctx, trustRound)
if err != nil {
return []byte{}, fmt.Errorf("could not get round %d: %w", trustRound, err)
Expand All @@ -146,7 +146,7 @@ func (v *verifyingClient) getTrustedPreviousSignature(ctx context.Context, round

ipk := info.PublicKey.Clone()
if err := chain.VerifyBeacon(ipk, &b); err != nil {
v.log.Warn("verifying_client", "failed to verify value", "b", b, "err", err)
v.log.Warnw("", "verifying_client", "failed to verify value", "b", b, "err", err)
return []byte{}, fmt.Errorf("verifying beacon: %w", err)
}
trustPrevSig = next.Signature()
Expand Down
8 changes: 4 additions & 4 deletions cmd/client/lib/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,19 @@ func buildHTTPClients(c *cli.Context, info **chain.Info, hash []byte, withInstru
if *info != nil {
hc, err = http.NewWithInfo(url, *info, nhttp.DefaultTransport)
if err != nil {
log.DefaultLogger().Warn("client", "failed to load URL", "url", url, "err", err)
log.DefaultLogger().Warnw("", "client", "failed to load URL", "url", url, "err", err)
continue
}
} else {
hc, err = http.New(url, hash, nhttp.DefaultTransport)
if err != nil {
log.DefaultLogger().Warn("client", "failed to load URL", "url", url, "err", err)
log.DefaultLogger().Warnw("", "client", "failed to load URL", "url", url, "err", err)
skipped = append(skipped, url)
continue
}
*info, err = hc.Info(context.Background())
if err != nil {
log.DefaultLogger().Warn("client", "failed to load Info from URL", "url", url, "err", err)
log.DefaultLogger().Warnw("", "client", "failed to load Info from URL", "url", url, "err", err)
continue
}
}
Expand All @@ -201,7 +201,7 @@ func buildHTTPClients(c *cli.Context, info **chain.Info, hash []byte, withInstru
for _, url := range skipped {
hc, err = http.NewWithInfo(url, *info, nhttp.DefaultTransport)
if err != nil {
log.DefaultLogger().Warn("client", "failed to load URL", "url", url, "err", err)
log.DefaultLogger().Warnw("", "client", "failed to load URL", "url", url, "err", err)
continue
}
clients = append(clients, hc)
Expand Down
2 changes: 1 addition & 1 deletion cmd/relay-s3/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func watch(ctx context.Context, c client.Watcher, upr *s3manager.Uploader, buc s
select {
case res, ok := <-ch:
if !ok {
log.DefaultLogger().Warn("relay_s3", "watch channel closed")
log.DefaultLogger().Warnw("", "relay_s3", "watch channel closed")
t := time.NewTimer(time.Second)
select {
case <-t.C:
Expand Down
2 changes: 1 addition & 1 deletion cmd/relay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func Relay(c *cli.Context) error {
rr := httptest.NewRecorder()
handler.ServeHTTP(rr, req)
if rr.Code != http.StatusOK {
log.DefaultLogger().Warn("binary", "relay", "startup failed", rr.Code)
log.DefaultLogger().Warnw("", "binary", "relay", "startup failed", rr.Code)
}

fmt.Printf("Listening at %s\n", listener.Addr())
Expand Down
2 changes: 1 addition & 1 deletion core/drand_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ func (d *Drand) pushDKGInfo(outgoing, incoming []*key.Node, previousThreshold in
d.log.Infow("", "push_dkg", "sending_group", "status", "enough succeeded", "missed", total)
return nil
}
d.log.Warn("push_dkg", "sending_group", "status", "timeout")
d.log.Warnw("", "push_dkg", "sending_group", "status", "timeout")
return errors.New("push group timeout")
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/drand_interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (d *Drand) NodeVersionValidator(ctx context.Context, req interface{},

rcvVer := utils.Version{Major: v.Major, Minor: v.Minor, Patch: v.Patch}
if !d.version.IsCompatible(rcvVer) {
d.log.Warn("node_version_interceptor", "node version rcv is no compatible --> rejecting message", "version", rcvVer)
d.log.Warnw("", "node_version_interceptor", "node version rcv is no compatible --> rejecting message", "version", rcvVer)
return nil, status.Error(codes.PermissionDenied, "Node Version not valid")
}

Expand All @@ -61,7 +61,7 @@ func (d *Drand) NodeVersionStreamValidator(srv interface{}, ss grpc.ServerStream

rcvVer := utils.Version{Major: v.Major, Minor: v.Minor, Patch: v.Patch}
if !d.version.IsCompatible(rcvVer) {
d.log.Warn("node_version_interceptor", "node version rcv is no compatible --> rejecting message", "version", rcvVer)
d.log.Warnw("", "node_version_interceptor", "node version rcv is no compatible --> rejecting message", "version", rcvVer)
return status.Error(codes.PermissionDenied, "Node Version not valid")
}

Expand Down
36 changes: 19 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ require (
github.com/gogo/googleapis v1.4.0 // indirect
github.com/gogo/status v1.1.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.1.1
github.com/google/uuid v1.3.0
github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.4 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.2.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/grpc-ecosystem/grpc-gateway v1.14.6
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/go-multierror v1.1.0
github.com/hashicorp/golang-lru v0.5.4
github.com/ipfs/go-cid v0.0.6-0.20200501230655-7c82f3b81c00 // indirect
Expand All @@ -42,19 +42,19 @@ require (
github.com/prometheus/procfs v0.1.0 // indirect
github.com/sercand/kuberesolver v2.4.0+incompatible // indirect
github.com/sirupsen/logrus v1.6.0 // indirect
github.com/stretchr/testify v1.5.1
github.com/stretchr/testify v1.7.0
github.com/uber/jaeger-client-go v2.23.1+incompatible // indirect
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
github.com/urfave/cli/v2 v2.2.0
github.com/weaveworks/common v0.0.0-20200512154658-384f10054ec5
go.etcd.io/bbolt v1.3.4
go.uber.org/zap v1.15.0
go.uber.org/zap v1.17.0
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
golang.org/x/net v0.0.0-20200602114024-627f9648deb9
golang.org/x/sys v0.0.0-20200926100807-9d91bd62050c
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
google.golang.org/genproto v0.0.0-20200608115520-7c474a2e3482 // indirect
google.golang.org/grpc v1.32.0
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
google.golang.org/grpc v1.38.0
google.golang.org/protobuf v1.27.1
)

Expand All @@ -64,19 +64,20 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd v0.20.1-beta // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20190912175916-7055855a373f // indirect
github.com/dgraph-io/badger/v2 v2.0.3 // indirect
github.com/dgraph-io/ristretto v0.0.2 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6 // indirect
github.com/go-kit/kit v0.10.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/google/gopacket v1.1.17 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
Expand Down Expand Up @@ -147,9 +148,10 @@ require (
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
go.dedis.ch/fixbuf v1.0.3 // indirect
go.dedis.ch/protobuf v1.0.11 // indirect
go.opencensus.io v0.22.3 // indirect
go.uber.org/atomic v1.6.0 // indirect
go.uber.org/multierr v1.5.0 // indirect
golang.org/x/text v0.3.2 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
go.opencensus.io v0.23.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
Loading

0 comments on commit 136181d

Please sign in to comment.