From 49bfbecc4e3f376659a1df5ec4bf362884860b19 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Tue, 15 Oct 2024 15:19:22 +0200 Subject: [PATCH] build: add CriticalS to ShutdownLogger Ensure that the ShutdownLogger correctly calls shutdown for the new CriticalS method added to the btclog.Logger. --- build/log_shutdown.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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() +}