Skip to content

Commit

Permalink
Merge pull request #1269 from lightninglabs/improve-logging
Browse files Browse the repository at this point in the history
Improve logging
  • Loading branch information
ffranr authored Jan 7, 2025
2 parents 0f68226 + ee22f42 commit 8719b40
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
13 changes: 12 additions & 1 deletion fn/option.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
package fn

// Option[A] represents a value which may or may not be there. This is very
import "fmt"

// Option represents a value which may or may not be there. This is very
// often preferable to nil-able pointers.
type Option[A any] struct {
isSome bool
some A
}

// String returns a string representation of the Option.
func (o Option[A]) String() string {
if o.isSome {
return fmt.Sprintf("Some(%v)", o.some)
}

return "None"
}

// Some trivially injects a value into an optional context.
//
// Some : A -> Option[A].
Expand Down
12 changes: 11 additions & 1 deletion rfq/negotiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ func (n *Negotiator) queryBidFromPriceOracle(assetSpecifier asset.Specifier,
ctx, cancel := n.WithCtxQuitNoTimeout()
defer cancel()

log.Debugf("Querying price oracle for bid price (asset_specifier=%s, "+
"asset_max_amt=%s, payment_max_amt=%s, asset_rate_hint=%s)",
assetSpecifier.String(), assetMaxAmt.String(),
paymentMaxAmt.String(), assetRateHint.String())

oracleResponse, err := n.cfg.PriceOracle.QueryBidPrice(
ctx, assetSpecifier, assetMaxAmt, paymentMaxAmt, assetRateHint,
)
Expand Down Expand Up @@ -240,6 +245,11 @@ func (n *Negotiator) queryAskFromPriceOracle(assetSpecifier asset.Specifier,
ctx, cancel := n.WithCtxQuitNoTimeout()
defer cancel()

log.Debugf("Querying price oracle for ask price (asset_specifier=%s, "+
"asset_max_amt=%s, payment_max_amt=%s, asset_rate_hint=%s)",
assetSpecifier.String(), assetMaxAmt.String(),
paymentMaxAmt.String(), assetRateHint.String())

oracleResponse, err := n.cfg.PriceOracle.QueryAskPrice(
ctx, assetSpecifier, assetMaxAmt, paymentMaxAmt,
assetRateHint,
Expand Down Expand Up @@ -439,7 +449,7 @@ func (n *Negotiator) HandleIncomingSellRequest(
sendOutgoingMsg(msg)

// Add an error to the error channel and return.
err = fmt.Errorf("failed to query ask price from "+
err = fmt.Errorf("failed to query bid price from "+
"oracle: %w", err)
n.cfg.ErrChan <- err
return
Expand Down
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,8 @@ func (s *Server) ChannelFinalized(pid funding.PendingChanID) error {
func (s *Server) ShouldHandleTraffic(cid lnwire.ShortChannelID,
fundingBlob lfn.Option[tlv.Blob]) (bool, error) {

srvrLog.Debugf("HandleTraffic called, cid=%v, fundingBlob=%v", cid,
spew.Sdump(fundingBlob))
srvrLog.Debugf("HandleTraffic called (cid=%v, fundingBlob=%x)", cid,
fundingBlob.UnwrapOr(tlv.Blob{}))

if err := s.waitForReady(); err != nil {
return false, err
Expand Down
4 changes: 2 additions & 2 deletions tapchannel/aux_funding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2218,8 +2218,8 @@ func (f *FundingController) CanHandle(msg msgmux.PeerMsg) bool {
return true
}

log.Debugf("Failed to handle: %T", msg.Message)

log.Tracef("FundingController encountered an unsupported message "+
"type: %T", msg.Message)
return false
}

Expand Down
2 changes: 1 addition & 1 deletion universe/auto_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (f *FederationEnvoy) Stop() error {
func (f *FederationEnvoy) syncServerState(ctx context.Context,
addr ServerAddr, syncConfigs SyncConfigs) error {

log.Infof("Syncing Universe state with server=%v", spew.Sdump(addr))
log.Infof("Syncing Universe state with server=%s", addr.HostStr())

// Attempt to sync with the remote Universe server, if this errors then
// we'll bail out early as something wrong happened.
Expand Down

0 comments on commit 8719b40

Please sign in to comment.