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

lightningnetwork / lnd / 13236757158

10 Feb 2025 08:39AM UTC coverage: 57.649% (-1.2%) from 58.815%
13236757158

Pull #9493

github

ziggie1984
lncli: for some cmds we don't replace the data of the response.

For some cmds it is not very practical to replace the json output
because we might pipe it into other commands. For example when
creating the route we want to pipe it into sendtoRoute.
Pull Request #9493: For some lncli cmds we should not replace the content with other data

0 of 9 new or added lines in 2 files covered. (0.0%)

19535 existing lines in 252 files now uncovered.

103517 of 179563 relevant lines covered (57.65%)

24878.49 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:ll
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
        NoCommitHash bool              `long:"no-commit-hash" description:"If set, the commit-hash of the current build will not be included in log lines by default."`
31
}
32

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

UNCOV
40
        return nil
×
41
}
42

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

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

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

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

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

UNCOV
88
        return opts
×
89
}
90

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