paymentsdb: add subsystem logging for payments package
What changed, and why it matters
This commit adds a new logging subsystem for the payments database package in LND. It only introduces logging infrastructure (a logger variable, subsystem name, and registration with the main logger setup) and does not change any payment-handling logic, database queries, or security behavior. There is no security issue visible in this change.
No security action needed. Review as normal code-quality/logging change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff creates payments/db/log.go, defining a package-level btclog.Logger, a ‘PYDB’ subsystem constant, init-time logger setup, DisableLog(), and UseLogger(). It also registers the new subsystem in the root log.go SetupLoggers() function. No functional code paths are modified; this is purely observability/instrumentation plumbing.
Changed components
payments/dblog.goInspect captured patch +39 / −0
diff --git a/log.go b/log.go
index 49ee5af..2484a35 100644
--- a/log.go
+++ b/log.go
@@ -46,6 +46,7 @@ import (
"github.com/lightningnetwork/lnd/monitoring"
"github.com/lightningnetwork/lnd/msgmux"
"github.com/lightningnetwork/lnd/netann"
+ paymentsdb "github.com/lightningnetwork/lnd/payments/db"
"github.com/lightningnetwork/lnd/peer"
"github.com/lightningnetwork/lnd/peernotifier"
"github.com/lightningnetwork/lnd/protofsm"
@@ -207,6 +208,10 @@ func SetupLoggers(root *build.SubLoggerManager, interceptor signal.Interceptor)
AddSubLogger(root, chainio.Subsystem, interceptor, chainio.UseLogger)
AddSubLogger(root, msgmux.Subsystem, interceptor, msgmux.UseLogger)
AddSubLogger(root, sqldb.Subsystem, interceptor, sqldb.UseLogger)
+ AddSubLogger(
+ root, paymentsdb.Subsystem, interceptor, paymentsdb.UseLogger,
+ )
+
}
// AddSubLogger is a helper method to conveniently create and register the
diff --git a/payments/db/log.go b/payments/db/log.go
new file mode 100644
index 0000000..08994ef
--- /dev/null
+++ b/payments/db/log.go
@@ -0,0 +1,34 @@
+package paymentsdb
+
+import (
+ "github.com/btcsuite/btclog/v2"
+ "github.com/lightningnetwork/lnd/build"
+)
+
+// log is a logger that is initialized with no output filters. This
+// means the package will not perform any logging by default until the caller
+// requests it.
+//
+//nolint:unused
+var log btclog.Logger
+
+// Subsystem defines the logging identifier for this subsystem.
+const Subsystem = "PYDB"
+
+// The default amount of logging is none.
+func init() {
+ UseLogger(build.NewSubLogger(Subsystem, nil))
+}
+
+// DisableLog disables all library log output. Logging output is disabled
+// by default until UseLogger is called.
+func DisableLog() {
+ UseLogger(btclog.Disabled)
+}
+
+// UseLogger uses a specified Logger to output package logging info.
+// This should be used in preference to SetLogWriter if the caller is also
+// using btclog.
+func UseLogger(logger btclog.Logger) {
+ log = logger
+}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.