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

lightningnetwork / lnd / 12293715361

12 Dec 2024 09:38AM UTC coverage: 57.483% (+7.9%) from 49.538%
12293715361

Pull #9348

github

ziggie1984
github: update goveralls tool

The goverall tool had a bug regarding the module versioning of
golang packages see also
https://github.com/mattn/goveralls/pull/222 for more background.
Goveralls is wrapped by another library to make it available for
github actions. So the relevant PR which is referenced here in
LND is:
https://github.com/shogo82148/actions-goveralls/pull/521.
Pull Request #9348: github: update goveralls tool

101897 of 177264 relevant lines covered (57.48%)

24982.4 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.
57
func SupportedLogCompressor(logCompressor string) bool {
×
58
        _, ok := logCompressors[logCompressor]
×
59

×
60
        return ok
×
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 {
669✔
68

669✔
69
        switch Deployment {
669✔
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:
669✔
82
                switch LoggingType {
669✔
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.
87
                case LogTypeDefault:
×
88
                        if genSubLogger != nil {
×
89
                                return genSubLogger(subsystem)
×
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
669✔
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