summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-09-10 18:28:19 +0800
committerKeuin <[email protected]>2022-09-10 18:28:19 +0800
commit73b2b41e777614d7c372b9d92a90b5fbb68d05c0 (patch)
tree39bf028dbe68347444dc25abdfd29d1cad7d2989 /common
parent5664705557ad5e4a3bd1234b12e4054a1a9579c1 (diff)
Replace all logger usages to custom logging.Logger.
Diffstat (limited to 'common')
-rw-r--r--common/retry.go8
1 files changed, 4 insertions, 4 deletions
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