-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug.go
More file actions
27 lines (22 loc) · 759 Bytes
/
debug.go
File metadata and controls
27 lines (22 loc) · 759 Bytes
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
package akamai
import "context"
// AkamaiContext is a context value type used to enable various features of the go-akamai library.
type AkamaiContext int
// AkamaiDebug is a context value that can be set to enable debug logging in the go-akamai library.
const AkamaiDebug AkamaiContext = 0
// WithDebugEnabled returns a copy of the parent context with debug enabled.
func WithDebugEnabled(ctx context.Context) context.Context {
if ctx == nil {
ctx = context.Background()
}
return context.WithValue(ctx, AkamaiDebug, true)
}
// DebugEnabled returns true if the context has debug enabled.
func DebugEnabled(ctx context.Context) bool {
if ctx == nil {
return false
}
debugAny := ctx.Value(AkamaiDebug)
debug, _ := debugAny.(bool)
return debug
}