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

lightningnetwork / lnd / 12058234999

27 Nov 2024 09:06PM UTC coverage: 57.847% (-1.1%) from 58.921%
12058234999

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%)

19365 existing lines in 251 files now uncovered.

100876 of 174383 relevant lines covered (57.85%)

25338.28 hits per line

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

36.11
/build/config.go
1
package build
2

3
import (
4
        "fmt"
5

6
        "github.com/btcsuite/btclog/v2"
7
)
8

9
const (
10
        callSiteOff   = "off"
11
        callSiteShort = "short"
12
        callSiteLong  = "long"
13

14
        defaultLogCompressor = Gzip
15

16
        // DefaultMaxLogFiles is the default maximum number of log files to
17
        // keep.
18
        DefaultMaxLogFiles = 10
19

20
        // DefaultMaxLogFileSize is the default maximum log file size in MB.
21
        DefaultMaxLogFileSize = 20
22
)
23

24
// LogConfig holds logging configuration options.
25
//
26
//nolint:lll
27
type LogConfig struct {
28
        Console *consoleLoggerCfg `group:"console" namespace:"console" description:"The logger writing to stdout and stderr."`
29
        File    *FileLoggerConfig `group:"file" namespace:"file" description:"The logger writing to LND's standard log file."`
30
}
31

32
// Validate validates the LogConfig struct values.
UNCOV
33
func (c *LogConfig) Validate() error {
×
UNCOV
34
        if !SupportedLogCompressor(c.File.Compressor) {
×
35
                return fmt.Errorf("invalid log compressor: %v",
×
36
                        c.File.Compressor)
×
37
        }
×
38

UNCOV
39
        return nil
×
40
}
41

42
// LoggerConfig holds options for a particular logger.
43
//
44
//nolint:lll
45
type LoggerConfig struct {
46
        Disable      bool   `long:"disable" description:"Disable this logger."`
47
        NoTimestamps bool   `long:"no-timestamps" description:"Omit timestamps from log lines."`
48
        CallSite     string `long:"call-site" description:"Include the call-site of each log line." choice:"off" choice:"short" choice:"long"`
49
}
50

51
// DefaultLogConfig returns the default logging config options.
52
func DefaultLogConfig() *LogConfig {
1✔
53
        return &LogConfig{
1✔
54
                Console: defaultConsoleLoggerCfg(),
1✔
55
                File: &FileLoggerConfig{
1✔
56
                        Compressor:     defaultLogCompressor,
1✔
57
                        MaxLogFiles:    DefaultMaxLogFiles,
1✔
58
                        MaxLogFileSize: DefaultMaxLogFileSize,
1✔
59
                        LoggerConfig: LoggerConfig{
1✔
60
                                CallSite: callSiteOff,
1✔
61
                        },
1✔
62
                },
1✔
63
        }
1✔
64
}
1✔
65

66
// HandlerOptions returns the set of btclog.HandlerOptions that the state of the
67
// config struct translates to.
UNCOV
68
func (cfg *LoggerConfig) HandlerOptions() []btclog.HandlerOption {
×
UNCOV
69
        opts := []btclog.HandlerOption{
×
UNCOV
70
                // We wrap the logger provided by the logging library with
×
UNCOV
71
                // another layer of abstraction with the handlerSet, and so we
×
UNCOV
72
                // need to increase the default skip depth by 1.
×
UNCOV
73
                btclog.WithCallSiteSkipDepth(btclog.DefaultSkipDepth + 1),
×
UNCOV
74
        }
×
UNCOV
75

×
UNCOV
76
        if cfg.NoTimestamps {
×
77
                opts = append(opts, btclog.WithNoTimestamp())
×
78
        }
×
79

UNCOV
80
        switch cfg.CallSite {
×
UNCOV
81
        case callSiteShort:
×
UNCOV
82
                opts = append(opts, btclog.WithCallerFlags(btclog.Lshortfile))
×
83
        case callSiteLong:
×
84
                opts = append(opts, btclog.WithCallerFlags(btclog.Llongfile))
×
85
        }
86

UNCOV
87
        return opts
×
88
}
89

90
// FileLoggerConfig extends LoggerConfig with specific log file options.
91
//
92
//nolint:lll
93
type FileLoggerConfig struct {
94
        LoggerConfig
95
        Compressor     string `long:"compressor" description:"Compression algorithm to use when rotating logs." choice:"gzip" choice:"zstd"`
96
        MaxLogFiles    int    `long:"max-files" description:"Maximum logfiles to keep (0 for no rotation)"`
97
        MaxLogFileSize int    `long:"max-file-size" description:"Maximum logfile size in MB"`
98
}
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