mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
rebase: vendor files required for kmip
Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
27
vendor/github.com/gemalto/flume/context.go
generated
vendored
Normal file
27
vendor/github.com/gemalto/flume/context.go
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
package flume
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// DefaultLogger is returned by FromContext if no other logger has been
|
||||
// injected into the context.
|
||||
var DefaultLogger = New("")
|
||||
|
||||
type ctxKey struct{}
|
||||
|
||||
var loggerKey = &ctxKey{}
|
||||
|
||||
// WithLogger returns a new context with the specified logger injected into it.
|
||||
func WithLogger(ctx context.Context, l Logger) context.Context {
|
||||
return context.WithValue(ctx, loggerKey, l)
|
||||
}
|
||||
|
||||
// FromContext returns a logger from the context. If the context
|
||||
// doesn't contain a logger, the DefaultLogger will be returned.
|
||||
func FromContext(ctx context.Context) Logger {
|
||||
if l, ok := ctx.Value(loggerKey).(Logger); ok {
|
||||
return l
|
||||
}
|
||||
return DefaultLogger
|
||||
}
|
Reference in New Issue
Block a user