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

lightningnetwork / lnd / 13536249039

26 Feb 2025 03:42AM UTC coverage: 57.462% (-1.4%) from 58.835%
13536249039

Pull #8453

github

Roasbeef
peer: update chooseDeliveryScript to gen script if needed

In this commit, we update `chooseDeliveryScript` to generate a new
script if needed. This allows us to fold in a few other lines that
always followed this function into this expanded function.

The tests have been updated accordingly.
Pull Request #8453: [4/4] - multi: integrate new rbf coop close FSM into the existing peer flow

275 of 1318 new or added lines in 22 files covered. (20.86%)

19521 existing lines in 257 files now uncovered.

103858 of 180741 relevant lines covered (57.46%)

24750.23 hits per line

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

14.63
/build/log.go
1
package build
2

3
import (
4
        "os"
5

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

9
// LogType is an indicating the type of logging specified by the build flag.
10
type LogType byte
11

12
const (
13
        // LogTypeNone indicates no logging.
14
        LogTypeNone LogType = iota
15

16
        // LogTypeStdOut all logging is written directly to stdout.
17
        LogTypeStdOut
18

19
        // LogTypeDefault logs to both stdout and a given io.PipeWriter.
20
        LogTypeDefault
21
)
22

23
// String returns a human readable identifier for the logging type.
24
func (t LogType) String() string {
×
25
        switch t {
×
26
        case LogTypeNone:
×
27
                return "none"
×
28
        case LogTypeStdOut:
×
29
                return "stdout"
×
30
        case LogTypeDefault:
×
31
                return "default"
×
32
        default:
×
33
                return "unknown"
×
34
        }
35
}
36

37
// Declare the supported log file compressors as exported consts for easier use
38
// from other projects.
39
const (
40
        // Gzip is the default compressor.
41
        Gzip = "gzip"
42

43
        // Zstd is a modern compressor that compresses better than Gzip, in less
44
        // time.
45
        Zstd = "zstd"
46
)
47

48
// logCompressors maps the identifier for each supported compression algorithm
49
// to the extension used for the compressed log files.
50
var logCompressors = map[string]string{
51
        Gzip: "gz",
52
        Zstd: "zst",
53
}
54

55
// SupportedLogCompressor returns whether or not logCompressor is a supported
56
// compression algorithm for log files.
UNCOV
57
func SupportedLogCompressor(logCompressor string) bool {
×
UNCOV
58
        _, ok := logCompressors[logCompressor]
×
UNCOV
59

×
UNCOV
60
        return ok
×
UNCOV
61
}
×
62

63
// NewSubLogger constructs a new subsystem log from the current LogWriter
64
// implementation. This is primarily intended for use with stdlog, as the actual
65
// writer is shared amongst all instantiations.
66
func NewSubLogger(subsystem string,
67
        genSubLogger func(string) btclog.Logger) btclog.Logger {
712✔
68

712✔
69
        switch Deployment {
712✔
70

71
        // For production builds, generate a new subsystem logger from the
72
        // primary log backend. If no function is provided, logging will be
73
        // disabled.
74
        case Production:
×
75
                if genSubLogger != nil {
×
76
                        return genSubLogger(subsystem)
×
77
                }
×
78

79
        // For development builds, we must handle two distinct types of logging:
80
        // unit tests and running the live daemon, e.g. for integration testing.
81
        case Development:
712✔
82
                switch LoggingType {
712✔
83

84
                // Default logging is used when running the standalone daemon.
85
                // We'll use the optional sublogger constructor to mimic the
86
                // production behavior.
UNCOV
87
                case LogTypeDefault:
×
UNCOV
88
                        if genSubLogger != nil {
×
UNCOV
89
                                return genSubLogger(subsystem)
×
UNCOV
90
                        }
×
91

92
                // Logging to stdout is used in unit tests. It is not important
93
                // that they share the same backend, since all output is written
94
                // to std out.
95
                case LogTypeStdOut:
×
96
                        backend := btclog.NewDefaultHandler(os.Stdout)
×
97
                        logger := btclog.NewSLogger(
×
98
                                backend.SubSystem(subsystem),
×
99
                        )
×
100

×
101
                        // Set the logging level of the stdout logger to use the
×
102
                        // configured logging level specified by build flags.
×
103
                        level, _ := btclog.LevelFromString(LogLevel)
×
104
                        logger.SetLevel(level)
×
105

×
106
                        return logger
×
107
                }
108
        }
109

110
        // For any other configurations, we'll disable logging.
111
        return btclog.Disabled
712✔
112
}
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