Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(i): Convert error logs to ErrorE func #2738

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require (
github.com/multiformats/go-multicodec v0.9.0
github.com/multiformats/go-multihash v0.2.3
github.com/sourcenetwork/badger/v4 v4.2.1-0.20231113215945-a63444ca5276
github.com/sourcenetwork/corelog v0.0.7
github.com/sourcenetwork/corelog v0.0.8
github.com/sourcenetwork/go-libp2p-pubsub-rpc v0.0.14
github.com/sourcenetwork/graphql-go v0.7.10-0.20231113214537-a9560c1898dd
github.com/sourcenetwork/immutable v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1073,8 +1073,8 @@ github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIK
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
github.com/sourcenetwork/badger/v4 v4.2.1-0.20231113215945-a63444ca5276 h1:TpQDDPfucDgCNH0NVqVUk6SSq6T6G8p9HIocmwZh9Tg=
github.com/sourcenetwork/badger/v4 v4.2.1-0.20231113215945-a63444ca5276/go.mod h1:lxiZTDBw0vheFMqSwX2OvB6RTDI1+/UtVCSU4rpThFM=
github.com/sourcenetwork/corelog v0.0.7 h1:vztssVAUDcsYN5VUOW3PKYhLprHfzoc8UbKewQuD1qw=
github.com/sourcenetwork/corelog v0.0.7/go.mod h1:cMabHgs3kARgYTQeQYSOmaGGP8XMU6sZrHd8LFrL3zA=
github.com/sourcenetwork/corelog v0.0.8 h1:jCo0mFBpWrfhUCGzzN3uUtPGyQv3jnITdPO1s2ME3RY=
github.com/sourcenetwork/corelog v0.0.8/go.mod h1:cMabHgs3kARgYTQeQYSOmaGGP8XMU6sZrHd8LFrL3zA=
github.com/sourcenetwork/go-libp2p-pubsub-rpc v0.0.14 h1:620zKV4rOn7U5j/WsPkk4SFj0z9/pVV4bBx0BpZQgro=
github.com/sourcenetwork/go-libp2p-pubsub-rpc v0.0.14/go.mod h1:jUoQv592uUX1u7QBjAY4C+l24X9ArhPfifOqXpDHz4U=
github.com/sourcenetwork/graphql-go v0.7.10-0.20231113214537-a9560c1898dd h1:lmpW39/8wPJ0khWRhOcj7Bj0HYKbSmQ8rXMJw1cMB8U=
Expand Down
1 change: 0 additions & 1 deletion internal/db/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func (db *db) handleMerges(ctx context.Context, merges events.Subscription[event
ctx,
"Failed to execute merge",
err,
corelog.Any("Error", err),
corelog.Any("Event", merge))
}
if merge.Wg != nil {
Expand Down
2 changes: 1 addition & 1 deletion net/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (n *Node) Bootstrap(addrs []peer.AddrInfo) {
defer wg.Done()
err := n.host.Connect(n.ctx, pinfo)
if err != nil {
log.InfoContext(n.ctx, "Cannot connect to peer", corelog.Any("Error", err))
log.ErrorContextE(n.ctx, "Cannot connect to peer", err)
return
}
log.InfoContext(n.ctx, "Connected", corelog.Any("PeerID", pinfo.ID))
Expand Down
8 changes: 3 additions & 5 deletions net/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@
log.InfoContext(
p.ctx,
"Failure while reconnecting to a known peer",
corelog.Any("peer", id),
corelog.Any("error", err),
)
corelog.Any("peer", id))
}
}(id)
}
Expand Down Expand Up @@ -193,12 +191,12 @@
// close event emitters
if p.server.pubSubEmitter != nil {
if err := p.server.pubSubEmitter.Close(); err != nil {
log.InfoContext(p.ctx, "Could not close pubsub event emitter", corelog.Any("Error", err.Error()))
log.ErrorContextE(p.ctx, "Could not close pubsub event emitter", err)

Check warning on line 194 in net/peer.go

View check run for this annotation

Codecov / codecov/patch

net/peer.go#L194

Added line #L194 was not covered by tests
}
}
if p.server.pushLogEmitter != nil {
if err := p.server.pushLogEmitter.Close(); err != nil {
log.InfoContext(p.ctx, "Could not close push log event emitter", corelog.Any("Error", err.Error()))
log.ErrorContextE(p.ctx, "Could not close push log event emitter", err)

Check warning on line 199 in net/peer.go

View check run for this annotation

Codecov / codecov/patch

net/peer.go#L199

Added line #L199 was not covered by tests
}
}

Expand Down
10 changes: 5 additions & 5 deletions net/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@
var err error
s.pubSubEmitter, err = s.peer.host.EventBus().Emitter(new(EvtPubSub))
if err != nil {
log.InfoContext(s.peer.ctx, "could not create event emitter", corelog.String("Error", err.Error()))
log.ErrorContextE(s.peer.ctx, "could not create event emitter", err)
}
s.pushLogEmitter, err = s.peer.host.EventBus().Emitter(new(EvtReceivedPushLog))
if err != nil {
log.InfoContext(s.peer.ctx, "could not create event emitter", corelog.String("Error", err.Error()))
log.ErrorContextE(s.peer.ctx, "could not create event emitter", err)
}

return s, nil
Expand Down Expand Up @@ -167,7 +167,7 @@
if s.pushLogEmitter != nil {
byPeer, err := libpeer.Decode(req.Body.Creator)
if err != nil {
log.InfoContext(ctx, "could not decode the PeerID of the log creator", corelog.String("Error", err.Error()))
log.ErrorContextE(ctx, "could not decode the PeerID of the log creator", err)

Check warning on line 170 in net/server.go

View check run for this annotation

Codecov / codecov/patch

net/server.go#L170

Added line #L170 was not covered by tests
}
err = s.pushLogEmitter.Emit(EvtReceivedPushLog{
FromPeer: pid,
Expand All @@ -176,7 +176,7 @@
if err != nil {
// logging instead of returning an error because the event bus should
// not break the PushLog execution.
log.InfoContext(ctx, "could not emit push log event", corelog.String("Error", err.Error()))
log.ErrorContextE(ctx, "could not emit push log event", err)

Check warning on line 179 in net/server.go

View check run for this annotation

Codecov / codecov/patch

net/server.go#L179

Added line #L179 was not covered by tests
}
}
}()
Expand Down Expand Up @@ -349,7 +349,7 @@
Peer: from,
})
if err != nil {
log.InfoContext(s.peer.ctx, "could not emit pubsub event", corelog.Any("Error", err.Error()))
log.ErrorContextE(s.peer.ctx, "could not emit pubsub event", err)
}
}
}
Expand Down
Loading