VictoriaMetrics/vendor/github.com/aws/smithy-go/waiter/logger.go
Zakhar Bessarab 5b7e8d1309
vmbackup: update AWS SDK to v2 ()
* lib/backup/s3remote: update AWS SDK to v2

* Update lib/backup/s3remote/s3.go

Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>

* lib/backup/s3remote: refactor error handling

Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
2022-10-01 17:13:04 +03:00

37 lines
1.0 KiB
Go

package waiter
import (
"context"
"fmt"
"github.com/aws/smithy-go/logging"
"github.com/aws/smithy-go/middleware"
)
// Logger is the Logger middleware used by the waiter to log an attempt
type Logger struct {
// Attempt is the current attempt to be logged
Attempt int64
}
// ID representing the Logger middleware
func (*Logger) ID() string {
return "WaiterLogger"
}
// HandleInitialize performs handling of request in initialize stack step
func (m *Logger) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
logger := middleware.GetLogger(ctx)
logger.Logf(logging.Debug, fmt.Sprintf("attempting waiter request, attempt count: %d", m.Attempt))
return next.HandleInitialize(ctx, in)
}
// AddLogger is a helper util to add waiter logger after `SetLogger` middleware in
func (m Logger) AddLogger(stack *middleware.Stack) error {
return stack.Initialize.Insert(&m, "SetLogger", middleware.After)
}