blob: 8d70a03ff2f493847d1ff105510ffa98a9f513e7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
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)
}
|