diff options
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/aws/logger.go')
-rw-r--r-- | vendor/github.com/aws/aws-sdk-go/aws/logger.go | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/logger.go b/vendor/github.com/aws/aws-sdk-go/aws/logger.go new file mode 100644 index 0000000..db87188 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/logger.go | |||
@@ -0,0 +1,112 @@ | |||
1 | package aws | ||
2 | |||
3 | import ( | ||
4 | "log" | ||
5 | "os" | ||
6 | ) | ||
7 | |||
8 | // A LogLevelType defines the level logging should be performed at. Used to instruct | ||
9 | // the SDK which statements should be logged. | ||
10 | type LogLevelType uint | ||
11 | |||
12 | // LogLevel returns the pointer to a LogLevel. Should be used to workaround | ||
13 | // not being able to take the address of a non-composite literal. | ||
14 | func LogLevel(l LogLevelType) *LogLevelType { | ||
15 | return &l | ||
16 | } | ||
17 | |||
18 | // Value returns the LogLevel value or the default value LogOff if the LogLevel | ||
19 | // is nil. Safe to use on nil value LogLevelTypes. | ||
20 | func (l *LogLevelType) Value() LogLevelType { | ||
21 | if l != nil { | ||
22 | return *l | ||
23 | } | ||
24 | return LogOff | ||
25 | } | ||
26 | |||
27 | // Matches returns true if the v LogLevel is enabled by this LogLevel. Should be | ||
28 | // used with logging sub levels. Is safe to use on nil value LogLevelTypes. If | ||
29 | // LogLevel is nill, will default to LogOff comparison. | ||
30 | func (l *LogLevelType) Matches(v LogLevelType) bool { | ||
31 | c := l.Value() | ||
32 | return c&v == v | ||
33 | } | ||
34 | |||
35 | // AtLeast returns true if this LogLevel is at least high enough to satisfies v. | ||
36 | // Is safe to use on nil value LogLevelTypes. If LogLevel is nill, will default | ||
37 | // to LogOff comparison. | ||
38 | func (l *LogLevelType) AtLeast(v LogLevelType) bool { | ||
39 | c := l.Value() | ||
40 | return c >= v | ||
41 | } | ||
42 | |||
43 | const ( | ||
44 | // LogOff states that no logging should be performed by the SDK. This is the | ||
45 | // default state of the SDK, and should be use to disable all logging. | ||
46 | LogOff LogLevelType = iota * 0x1000 | ||
47 | |||
48 | // LogDebug state that debug output should be logged by the SDK. This should | ||
49 | // be used to inspect request made and responses received. | ||
50 | LogDebug | ||
51 | ) | ||
52 | |||
53 | // Debug Logging Sub Levels | ||
54 | const ( | ||
55 | // LogDebugWithSigning states that the SDK should log request signing and | ||
56 | // presigning events. This should be used to log the signing details of | ||
57 | // requests for debugging. Will also enable LogDebug. | ||
58 | LogDebugWithSigning LogLevelType = LogDebug | (1 << iota) | ||
59 | |||
60 | // LogDebugWithHTTPBody states the SDK should log HTTP request and response | ||
61 | // HTTP bodys in addition to the headers and path. This should be used to | ||
62 | // see the body content of requests and responses made while using the SDK | ||
63 | // Will also enable LogDebug. | ||
64 | LogDebugWithHTTPBody | ||
65 | |||
66 | // LogDebugWithRequestRetries states the SDK should log when service requests will | ||
67 | // be retried. This should be used to log when you want to log when service | ||
68 | // requests are being retried. Will also enable LogDebug. | ||
69 | LogDebugWithRequestRetries | ||
70 | |||
71 | // LogDebugWithRequestErrors states the SDK should log when service requests fail | ||
72 | // to build, send, validate, or unmarshal. | ||
73 | LogDebugWithRequestErrors | ||
74 | ) | ||
75 | |||
76 | // A Logger is a minimalistic interface for the SDK to log messages to. Should | ||
77 | // be used to provide custom logging writers for the SDK to use. | ||
78 | type Logger interface { | ||
79 | Log(...interface{}) | ||
80 | } | ||
81 | |||
82 | // A LoggerFunc is a convenience type to convert a function taking a variadic | ||
83 | // list of arguments and wrap it so the Logger interface can be used. | ||
84 | // | ||
85 | // Example: | ||
86 | // s3.New(sess, &aws.Config{Logger: aws.LoggerFunc(func(args ...interface{}) { | ||
87 | // fmt.Fprintln(os.Stdout, args...) | ||
88 | // })}) | ||
89 | type LoggerFunc func(...interface{}) | ||
90 | |||
91 | // Log calls the wrapped function with the arguments provided | ||
92 | func (f LoggerFunc) Log(args ...interface{}) { | ||
93 | f(args...) | ||
94 | } | ||
95 | |||
96 | // NewDefaultLogger returns a Logger which will write log messages to stdout, and | ||
97 | // use same formatting runes as the stdlib log.Logger | ||
98 | func NewDefaultLogger() Logger { | ||
99 | return &defaultLogger{ | ||
100 | logger: log.New(os.Stdout, "", log.LstdFlags), | ||
101 | } | ||
102 | } | ||
103 | |||
104 | // A defaultLogger provides a minimalistic logger satisfying the Logger interface. | ||
105 | type defaultLogger struct { | ||
106 | logger *log.Logger | ||
107 | } | ||
108 | |||
109 | // Log logs the parameters to the stdlib logger. See log.Println. | ||
110 | func (l defaultLogger) Log(args ...interface{}) { | ||
111 | l.logger.Println(args...) | ||
112 | } | ||