• 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

13.21
/build/config_dev.go
1
//go:build dev
2
// +build dev
3

4
package build
5

6
import (
7
        "fmt"
8
        "strings"
9

10
        btclogv1 "github.com/btcsuite/btclog"
11
        "github.com/btcsuite/btclog/v2"
12
)
13

14
const (
15
        resetSeq = "0"
16
        boldSeq  = "1"
17
        faintSeq = "2"
18
        esc      = '\x1b'
19
        csi      = string(esc) + "["
20
)
21

22
// consoleLoggerCfg extends the LoggerConfig struct by adding a Color option
23
// which is only available for a console logger.
24
//
25
//nolint:ll
26
type consoleLoggerCfg struct {
27
        LoggerConfig
28
        Style bool `long:"style" description:"If set, the output will be styled with color and fonts"`
29
}
30

31
// defaultConsoleLoggerCfg returns the default consoleLoggerCfg for the dev
32
// console logger.
33
func defaultConsoleLoggerCfg() *consoleLoggerCfg {
1✔
34
        return &consoleLoggerCfg{
1✔
35
                LoggerConfig: LoggerConfig{
1✔
36
                        CallSite: callSiteShort,
1✔
37
                },
1✔
38
        }
1✔
39
}
1✔
40

41
// HandlerOptions returns the set of btclog.HandlerOptions that the state of the
42
// config struct translates to.
UNCOV
43
func (cfg *consoleLoggerCfg) HandlerOptions() []btclog.HandlerOption {
×
UNCOV
44
        opts := cfg.LoggerConfig.HandlerOptions()
×
UNCOV
45

×
UNCOV
46
        if !cfg.Style {
×
UNCOV
47
                return opts
×
UNCOV
48
        }
×
49

50
        return append(
×
51
                opts, btclog.WithStyledLevel(
×
52
                        func(l btclogv1.Level) string {
×
53
                                return styleString(
×
54
                                        fmt.Sprintf("[%s]", l),
×
55
                                        boldSeq,
×
56
                                        string(ansiColoSeq(l)),
×
57
                                )
×
58
                        },
×
59
                ),
60
                btclog.WithStyledCallSite(
61
                        func(file string, line int) string {
×
62
                                str := fmt.Sprintf("%s:%d", file, line)
×
63

×
64
                                return styleString(str, faintSeq)
×
65
                        },
×
66
                ),
67
                btclog.WithStyledKeys(func(key string) string {
×
68
                        return styleString(key, faintSeq)
×
69
                }),
×
70
        )
71
}
72

73
func styleString(s string, styles ...string) string {
×
74
        if len(styles) == 0 {
×
75
                return s
×
76
        }
×
77

78
        seq := strings.Join(styles, ";")
×
79
        if seq == "" {
×
80
                return s
×
81
        }
×
82

83
        return fmt.Sprintf("%s%sm%s%sm", csi, seq, s, csi+resetSeq)
×
84
}
85

86
type ansiColorSeq string
87

88
const (
89
        ansiColorSeqDarkTeal  ansiColorSeq = "38;5;30"
90
        ansiColorSeqDarkBlue  ansiColorSeq = "38;5;63"
91
        ansiColorSeqLightBlue ansiColorSeq = "38;5;86"
92
        ansiColorSeqYellow    ansiColorSeq = "38;5;192"
93
        ansiColorSeqRed       ansiColorSeq = "38;5;204"
94
        ansiColorSeqPink      ansiColorSeq = "38;5;134"
95
)
96

97
func ansiColoSeq(l btclogv1.Level) ansiColorSeq {
×
98
        switch l {
×
99
        case btclog.LevelTrace:
×
100
                return ansiColorSeqDarkTeal
×
101
        case btclog.LevelDebug:
×
102
                return ansiColorSeqDarkBlue
×
103
        case btclog.LevelWarn:
×
104
                return ansiColorSeqYellow
×
105
        case btclog.LevelError:
×
106
                return ansiColorSeqRed
×
107
        case btclog.LevelCritical:
×
108
                return ansiColorSeqPink
×
109
        default:
×
110
                return ansiColorSeqLightBlue
×
111
        }
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