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

lightningnetwork / lnd / 11393106485

17 Oct 2024 09:10PM UTC coverage: 57.848% (-1.0%) from 58.81%
11393106485

Pull #9148

github

ProofOfKeags
lnwire: convert DynPropose and DynCommit to use typed tlv records
Pull Request #9148: DynComms [2/n]: lnwire: add authenticated wire messages for Dyn*

142 of 177 new or added lines in 4 files covered. (80.23%)

18983 existing lines in 242 files now uncovered.

99003 of 171143 relevant lines covered (57.85%)

36968.25 hits per line

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

72.22
/build/prefix_log.go
1
package build
2

3
import "github.com/btcsuite/btclog"
4

5
// PrefixLog is a pass-through logger that adds a prefix to every logged line.
6
type PrefixLog struct {
7
        log    btclog.Logger
8
        prefix string
9
}
10

11
// NewPrefixLog instantiates a new prefixed logger.
12
func NewPrefixLog(prefix string, log btclog.Logger) *PrefixLog {
1,136✔
13
        return &PrefixLog{
1,136✔
14
                prefix: prefix,
1,136✔
15
                log:    log,
1,136✔
16
        }
1,136✔
17
}
1,136✔
18

19
// addFormatPrefix prepends the prefix to a format string.
20
func (p *PrefixLog) addFormatPrefix(s string) string {
63,594✔
21
        return p.prefix + " " + s
63,594✔
22
}
63,594✔
23

24
// addArgsPrefix prepends the prefix to a list of arguments.
25
func (p *PrefixLog) addArgsPrefix(args []interface{}) []interface{} {
11,236✔
26
        return append([]interface{}{p.prefix}, args...)
11,236✔
27
}
11,236✔
28

29
// Tracef formats message according to format specifier and writes to to log
30
// with LevelTrace.
31
func (p *PrefixLog) Tracef(format string, params ...interface{}) {
47,331✔
32
        p.log.Tracef(p.addFormatPrefix(format), params...)
47,331✔
33
}
47,331✔
34

35
// Debugf formats message according to format specifier and writes to log with
36
// LevelDebug.
37
func (p *PrefixLog) Debugf(format string, params ...interface{}) {
11,642✔
38
        p.log.Debugf(p.addFormatPrefix(format), params...)
11,642✔
39
}
11,642✔
40

41
// Infof formats message according to format specifier and writes to log with
42
// LevelInfo.
43
func (p *PrefixLog) Infof(format string, params ...interface{}) {
2,909✔
44
        p.log.Infof(p.addFormatPrefix(format), params...)
2,909✔
45
}
2,909✔
46

47
// Warnf formats message according to format specifier and writes to to log with
48
// LevelWarn.
49
func (p *PrefixLog) Warnf(format string, params ...interface{}) {
849✔
50
        p.log.Warnf(p.addFormatPrefix(format), params...)
849✔
51
}
849✔
52

53
// Errorf formats message according to format specifier and writes to to log
54
// with LevelError.
55
func (p *PrefixLog) Errorf(format string, params ...interface{}) {
863✔
56
        p.log.Errorf(p.addFormatPrefix(format), params...)
863✔
57
}
863✔
58

59
// Criticalf formats message according to format specifier and writes to log
60
// with LevelCritical.
61
func (p *PrefixLog) Criticalf(format string, params ...interface{}) {
×
62
        p.log.Criticalf(p.addFormatPrefix(format), params...)
×
63
}
×
64

65
// Trace formats message using the default formats for its operands and writes
66
// to log with LevelTrace.
67
func (p *PrefixLog) Trace(v ...interface{}) {
10,635✔
68
        p.log.Trace(p.addArgsPrefix(v)...)
10,635✔
69
}
10,635✔
70

71
// Debug formats message using the default formats for its operands and writes
72
// to log with LevelDebug.
73
func (p *PrefixLog) Debug(v ...interface{}) {
2✔
74
        p.log.Debug(p.addArgsPrefix(v)...)
2✔
75
}
2✔
76

77
// Info formats message using the default formats for its operands and writes to
78
// log with LevelInfo.
79
func (p *PrefixLog) Info(v ...interface{}) {
582✔
80
        p.log.Info(p.addArgsPrefix(v)...)
582✔
81
}
582✔
82

83
// Warn formats message using the default formats for its operands and writes to
84
// log with LevelWarn.
85
func (p *PrefixLog) Warn(v ...interface{}) {
17✔
86
        p.log.Warn(p.addArgsPrefix(v)...)
17✔
87
}
17✔
88

89
// Error formats message using the default formats for its operands and writes
90
// to log with LevelError.
UNCOV
91
func (p *PrefixLog) Error(v ...interface{}) {
×
UNCOV
92
        p.log.Error(p.addArgsPrefix(v)...)
×
UNCOV
93
}
×
94

95
// Critical formats message using the default formats for its operands and
96
// writes to log with LevelCritical.
97
func (p *PrefixLog) Critical(v ...interface{}) {
×
98
        p.log.Critical(p.addArgsPrefix(v)...)
×
99
}
×
100

101
// Level returns the current logging level.
102
func (p *PrefixLog) Level() btclog.Level {
×
103
        return p.log.Level()
×
104
}
×
105

106
// SetLevel changes the logging level to the passed level.
107
func (p *PrefixLog) SetLevel(level btclog.Level) {
×
108
        p.log.SetLevel(level)
×
109
}
×
110

111
// Assert that PrefixLog fulfills the btclog.Logger interface.
112
var _ btclog.Logger = &PrefixLog{}
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