• 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

0.0
/build/log_shutdown.go
1
package build
2

3
import (
4
        "context"
5

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

9
// ShutdownLogger wraps an existing logger with a shutdown function which will
10
// be called on Critical/Criticalf to prompt shutdown.
11
type ShutdownLogger struct {
12
        btclog.Logger
13
        shutdown func()
14
}
15

16
// NewShutdownLogger creates a shutdown logger for the log provided which will
17
// use the signal package to request shutdown on critical errors.
UNCOV
18
func NewShutdownLogger(logger btclog.Logger, shutdown func()) *ShutdownLogger {
×
UNCOV
19
        return &ShutdownLogger{
×
UNCOV
20
                Logger:   logger,
×
UNCOV
21
                shutdown: shutdown,
×
UNCOV
22
        }
×
UNCOV
23
}
×
24

25
// Criticalf formats message according to format specifier and writes to
26
// log with LevelCritical. It will then call the shutdown logger's shutdown
27
// function to prompt safe shutdown.
28
//
29
// Note: it is part of the btclog.Logger interface.
30
func (s *ShutdownLogger) Criticalf(format string, params ...interface{}) {
×
31
        s.Logger.Criticalf(format, params...)
×
32
        s.Logger.Info("Sending request for shutdown")
×
33
        s.shutdown()
×
34
}
×
35

36
// Critical formats message using the default formats for its operands
37
// and writes to log with LevelCritical. It will then call the shutdown
38
// logger's shutdown function to prompt safe shutdown.
39
//
40
// Note: it is part of the btclog.Logger interface.
41
func (s *ShutdownLogger) Critical(v ...interface{}) {
×
42
        s.Logger.Critical(v)
×
43
        s.Logger.Info("Sending request for shutdown")
×
44
        s.shutdown()
×
45
}
×
46

47
// CriticalS writes a structured log with the given message and key-value pair
48
// attributes with LevelCritical to the log. It will then call the shutdown
49
// logger's shutdown function to prompt safe shutdown.
50
//
51
// Note: it is part of the btclog.Logger interface.
52
func (s *ShutdownLogger) CriticalS(ctx context.Context, msg string, err error,
53
        attr ...interface{}) {
×
54

×
55
        s.Logger.CriticalS(ctx, msg, err, attr...)
×
56
        s.Logger.Info("Sending request for shutdown")
×
57
        s.shutdown()
×
58
}
×
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