Skip to content

Commit

Permalink
chore: reduce logs (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz authored Aug 21, 2024
1 parent f0a36ca commit f09c3bc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
7 changes: 5 additions & 2 deletions lnclient/breez/breez.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ type BreezListener struct {
}

func (listener BreezListener) Log(l breez_sdk.LogEntry) {
if l.Level != "TRACE" && l.Level != "DEBUG" {
logger.Logger.WithField("level", l.Level).Print(l.Line)
logLevel := logrus.InfoLevel
if l.Level == "TRACE" || l.Level == "DEBUG" || strings.Contains(l.Line, "connection to node lost") || strings.Contains(l.Line, "Restore channel") {
logLevel = logrus.DebugLevel
}

logger.Logger.WithField("level", l.Level).Log(logLevel, l.Line)
}

func (BreezListener) OnEvent(e breez_sdk.BreezEvent) {
Expand Down
2 changes: 1 addition & 1 deletion nip47/controllers/get_balance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (controller *nip47Controller) HandleGetBalanceEvent(ctx context.Context, ni

logger.Logger.WithFields(logrus.Fields{
"request_event_id": requestEventId,
}).Info("Getting balance")
}).Debug("Getting balance")

balance := uint64(0)
if app.Isolated {
Expand Down
2 changes: 1 addition & 1 deletion nip47/controllers/get_info_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (controller *nip47Controller) HandleGetInfoEvent(ctx context.Context, nip47
if hasPermission {
logger.Logger.WithFields(logrus.Fields{
"request_event_id": requestEventId,
}).Info("Getting info")
}).Debug("Getting info")

info, err := controller.lnClient.GetInfo(ctx)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion nip47/controllers/list_transactions_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (controller *nip47Controller) HandleListTransactionsEvent(ctx context.Conte
logger.Logger.WithFields(logrus.Fields{
"params": listParams,
"request_event_id": requestEventId,
}).Info("Fetching transactions")
}).Debug("Fetching transactions")

limit := listParams.Limit
maxLimit := uint64(50)
Expand Down
14 changes: 7 additions & 7 deletions nip47/event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (svc *nip47Service) HandleEvent(ctx context.Context, relay nostrmodels.Rela
"requestEventNostrId": event.ID,
"eventKind": event.Kind,
"appId": app.ID,
}).Info("App found for nostr event")
}).Debug("App found for nostr event")

//to be extra safe, decrypt using the key found from the app
ss, err = nip04.ComputeSharedSecret(app.NostrPubkey, svc.keys.GetNostrSecretKey())
Expand Down Expand Up @@ -245,11 +245,11 @@ func (svc *nip47Service) HandleEvent(ctx context.Context, relay nostrmodels.Rela
} else {
requestEvent.State = db.REQUEST_EVENT_STATE_HANDLER_EXECUTED
logger.Logger.WithFields(logrus.Fields{
"requestEventNostrId": event.ID,
"requestEventNostrId": event.ID,
"responseEventNostrId": resp.ID,
"eventKind": event.Kind,
"appId": app.ID,
}).Info("Published response")
"eventKind": event.Kind,
"appId": app.ID,
}).Debug("Published response")
}
}
err = svc.db.Save(&requestEvent).Error
Expand All @@ -266,7 +266,7 @@ func (svc *nip47Service) HandleEvent(ctx context.Context, relay nostrmodels.Rela
"appId": app.ID,
"method": nip47Request.Method,
"params": nip47Request.Params,
}).Info("Handling NIP-47 request")
}).Debug("Handling NIP-47 request")

if nip47Request.Method != models.GET_INFO_METHOD {
scope, err := permissions.RequestMethodToScope(nip47Request.Method)
Expand Down Expand Up @@ -417,7 +417,7 @@ func (svc *nip47Service) publishResponseEvent(ctx context.Context, relay nostrmo
"appId": appId,
"responseEventId": responseEvent.ID,
"responseNostrEventId": resp.ID,
}).Info("Published reply")
}).Debug("Published reply")
}

err = svc.db.Save(&responseEvent).Error
Expand Down
4 changes: 2 additions & 2 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ func (svc *service) StartSubscription(ctx context.Context, sub *nostr.Subscripti
go func() {
// block till EOS is received
<-sub.EndOfStoredEvents
logger.Logger.Info("Received EOS")
logger.Logger.Debug("Received EOS")

// loop through incoming events
for event := range sub.Events {
go svc.nip47Service.HandleEvent(ctx, sub.Relay, event, svc.lnClient)
}
logger.Logger.Info("Relay subscription events channel ended")
logger.Logger.Debug("Relay subscription events channel ended")
}()

<-ctx.Done()
Expand Down

0 comments on commit f09c3bc

Please sign in to comment.