Skip to content

Commit

Permalink
create subscription logger, default error level
Browse files Browse the repository at this point in the history
  • Loading branch information
frrist committed Jun 20, 2019
1 parent 1ccea38 commit 5c9b751
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
23 changes: 12 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ func main() {

logging.SetAllLoggers(oldlogging.Level(n))

logging.SetLogLevel("dht", "error") // nolint: errcheck
logging.SetLogLevel("bitswap", "error") // nolint: errcheck
logging.SetLogLevel("heartbeat", "error") // nolint: errcheck
logging.SetLogLevel("blockservice", "error") // nolint: errcheck
logging.SetLogLevel("peerqueue", "error") // nolint: errcheck
logging.SetLogLevel("swarm", "error") // nolint: errcheck
logging.SetLogLevel("swarm2", "error") // nolint: errcheck
logging.SetLogLevel("basichost", "error") // nolint: errcheck
logging.SetLogLevel("dht_net", "error") // nolint: errcheck
logging.SetLogLevel("pubsub", "error") // nolint: errcheck
logging.SetLogLevel("relay", "error") // nolint: errcheck
logging.SetLogLevel("dht", "error") // nolint: errcheck
logging.SetLogLevel("bitswap", "error") // nolint: errcheck
logging.SetLogLevel("heartbeat", "error") // nolint: errcheck
logging.SetLogLevel("blockservice", "error") // nolint: errcheck
logging.SetLogLevel("peerqueue", "error") // nolint: errcheck
logging.SetLogLevel("swarm", "error") // nolint: errcheck
logging.SetLogLevel("swarm2", "error") // nolint: errcheck
logging.SetLogLevel("basichost", "error") // nolint: errcheck
logging.SetLogLevel("dht_net", "error") // nolint: errcheck
logging.SetLogLevel("pubsub", "error") // nolint: errcheck
logging.SetLogLevel("relay", "error") // nolint: errcheck
logging.SetLogLevel("node/subscription", "error") // nolint: errcheck

// TODO implement help text like so:
// https://github.com/ipfs/go-ipfs/blob/master/core/commands/root.go#L91
Expand Down
6 changes: 4 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1021,17 +1021,19 @@ func (node *Node) miningOwnerAddress(ctx context.Context, miningAddr address.Add
return ownerAddr, nil
}

var subscriptionLogger = logging.Logger("node/subscription")

func (node *Node) handleSubscription(ctx context.Context, f pubSubProcessorFunc, fname string, s pubsub.Subscription, sname string) {
for {
pubSubMsg, err := s.Next(ctx)
if err != nil {
log.Errorf("%s.Next(): %s", sname, err)
subscriptionLogger.Errorf("%s.Next(): %s", sname, err)
return
}

if err := f(ctx, pubSubMsg); err != nil {
if err != context.Canceled {
log.Errorf("%s(): %s", fname, err)
subscriptionLogger.Warningf("%s(): %s", fname, err)
}
}
}
Expand Down

0 comments on commit 5c9b751

Please sign in to comment.