build: add CriticalS to ShutdownLogger

Ensure that the ShutdownLogger correctly calls shutdown for the new
CriticalS method added to the btclog.Logger.
This commit is contained in:
Elle Mouton
2024-10-15 15:19:22 +02:00
parent ba1ce84b27
commit 49bfbecc4e

View File

@@ -1,6 +1,8 @@
package build
import (
"context"
"github.com/btcsuite/btclog/v2"
)
@@ -41,3 +43,16 @@ func (s *ShutdownLogger) Critical(v ...interface{}) {
s.Logger.Info("Sending request for shutdown")
s.shutdown()
}
// CriticalS writes a structured log with the given message and key-value pair
// attributes with LevelCritical to the log. It will then call the shutdown
// logger's shutdown function to prompt safe shutdown.
//
// Note: it is part of the btclog.Logger interface.
func (s *ShutdownLogger) CriticalS(ctx context.Context, msg string, err error,
attr ...interface{}) {
s.Logger.CriticalS(ctx, msg, err, attr...)
s.Logger.Info("Sending request for shutdown")
s.shutdown()
}