diff --git a/build/log_shutdown.go b/build/log_shutdown.go index 4d7605780..dfabe1cb6 100644 --- a/build/log_shutdown.go +++ b/build/log_shutdown.go @@ -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() +}