From 73b2b41e777614d7c372b9d92a90b5fbb68d05c0 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sat, 10 Sep 2022 18:28:19 +0800 Subject: Replace all logger usages to custom logging.Logger. --- common/retry.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common/retry.go') diff --git a/common/retry.go b/common/retry.go index 1751679..647e8ad 100644 --- a/common/retry.go +++ b/common/retry.go @@ -1,8 +1,8 @@ package common import ( + "bilibili-livestream-archiver/logging" "context" - "log" "time" ) @@ -15,14 +15,14 @@ func AutoRetry[T any]( supplier func() (T, error), maxRetryTimes int, retryInterval time.Duration, - logger *log.Logger) (T, error) { + logger *logging.Logger) (T, error) { var err error var ret T for i := 0; i < maxRetryTimes+1; i++ { ret, err = supplier() if err != nil { if logger != nil { - logger.Printf("Try %v/%v (sleep %vs): %v", + logger.Info("Try %v/%v (sleep %vs): %v", i, maxRetryTimes, retryInterval, err) } timer := time.NewTimer(retryInterval) @@ -40,7 +40,7 @@ func AutoRetry[T any]( return ret, nil } if logger != nil { - logger.Printf("Max retry times reached, but it still fails. Last error: %v", err) + logger.Error("Max retry times reached, but it still fails. Last error: %v", err) } var zero T return zero, err -- cgit v1.2.3