From 895849376edcff3408f0c5d34c92f80e4b8d971c Mon Sep 17 00:00:00 2001 From: yurii Date: Fri, 9 Jan 2026 16:26:34 +0000 Subject: [PATCH] improved logging for preauth releaser --- hardlink-preauth-release/main.go | 11 +++++++---- main.go | 2 +- payment/preauthReleaser.go | 6 +++--- release notes.md | 3 +++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/hardlink-preauth-release/main.go b/hardlink-preauth-release/main.go index 0dfa829..4570e5c 100644 --- a/hardlink-preauth-release/main.go +++ b/hardlink-preauth-release/main.go @@ -14,7 +14,7 @@ import ( ) const ( - buildVersion = "1.0.1" + buildVersion = "1.0.2" serviceName = "preauth-release" ) @@ -33,12 +33,15 @@ func main() { defer database.Close() if err := payment.ReleasePreauthorizations(database); err != nil { - log.WithError(err).Fatal("Preauth release failed") + log.Error(err) + fmt.Println(err) + } else { + log.Info("Task completed successfully") + fmt.Println("Task completed successfully") } - log.Info("Task completed successfully") for i := 20; i > 0; i-- { - fmt.Printf("\rExiting in %2d seconds...", i) + fmt.Printf("\rExiting in %2d seconds... ", i) time.Sleep(time.Second) } fmt.Println("\rExiting now. ") diff --git a/main.go b/main.go index 39c5b4c..e002cbd 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ import ( ) const ( - buildVersion = "1.0.29" + buildVersion = "1.0.30" serviceName = "hardlink" ) diff --git a/payment/preauthReleaser.go b/payment/preauthReleaser.go index b45d3e5..f77c5c8 100644 --- a/payment/preauthReleaser.go +++ b/payment/preauthReleaser.go @@ -21,7 +21,7 @@ const ( ) /* ============================== - Public Entry Point (LEGACY) + Public Entry Point ============================== */ func ReleasePreauthorizations(database *sql.DB) error { @@ -78,6 +78,7 @@ func handlePreauthRelease( if err != nil { return err } + log.Infof("res=%s state=%s", info.transactionRes, info.transactionState) // If already voided or declined → mark released if isAlreadyReleased(info) { @@ -86,8 +87,7 @@ func handlePreauthRelease( // Only void approved + uncommitted if !isVoidable(info) { - log.Infof("Preauth %s not eligible for void (res=%s state=%s)", - ref, info.transactionRes, info.transactionState) + log.Infof("Preauth %s not eligible for void (res=%s state=%s)", ref, info.transactionRes, info.transactionState) return nil } diff --git a/release notes.md b/release notes.md index 86b133f..38819ef 100644 --- a/release notes.md +++ b/release notes.md @@ -2,6 +2,9 @@ builtVersion is a const in main.go +#### 1.0.30 - 09 January 2026 +improved logging for preauth releaser + #### 1.0.29 - 08 January 2026 added count down before exiting the preauth releaser 20 seconds