• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 16683051882

01 Aug 2025 07:03PM UTC coverage: 54.949% (-12.1%) from 67.047%
16683051882

Pull #9455

github

web-flow
Merge 3f1f50be8 into 37523b6cb
Pull Request #9455: discovery+lnwire: add support for DNS host name in NodeAnnouncement msg

144 of 226 new or added lines in 7 files covered. (63.72%)

23852 existing lines in 290 files now uncovered.

108751 of 197912 relevant lines covered (54.95%)

22080.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.95
/lnutils/log.go
1
package lnutils
2

3
import (
4
        "log/slog"
5
        "strings"
6

7
        "github.com/btcsuite/btcd/btcec/v2"
8
        "github.com/btcsuite/btclog/v2"
9
        "github.com/davecgh/go-spew/spew"
10
)
11

12
// LogClosure is used to provide a closure over expensive logging operations so
13
// don't have to be performed when the logging level doesn't warrant it.
14
type LogClosure func() string
15

16
// String invokes the underlying function and returns the result.
17
func (c LogClosure) String() string {
6✔
18
        return c()
6✔
19
}
6✔
20

21
// NewLogClosure returns a new closure over a function that returns a string
22
// which itself provides a Stringer interface so that it can be used with the
23
// logging system.
24
func NewLogClosure(c func() string) LogClosure {
2,955✔
25
        return LogClosure(c)
2,955✔
26
}
2,955✔
27

28
// SpewLogClosure takes an interface and returns the string of it created from
29
// `spew.Sdump` in a LogClosure.
30
func SpewLogClosure(a any) LogClosure {
9,041✔
31
        return func() string {
9,047✔
32
                return spew.Sdump(a)
6✔
33
        }
6✔
34
}
35

36
// NewSeparatorClosure returns a new closure that logs a separator line.
37
func NewSeparatorClosure() LogClosure {
1✔
38
        return func() string {
1✔
UNCOV
39
                return strings.Repeat("=", 80)
×
UNCOV
40
        }
×
41
}
42

43
// LogPubKey returns a slog attribute for logging a public key in hex format.
44
func LogPubKey(key string, pubKey *btcec.PublicKey) slog.Attr {
36✔
45
        // Handle nil pubkey gracefully, although callers should ideally prevent
36✔
46
        // this.
36✔
47
        if pubKey == nil {
36✔
48
                return btclog.Fmt(key, "<nil>")
×
49
        }
×
50

51
        return btclog.Hex6(key, pubKey.SerializeCompressed())
36✔
52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc