mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
Adds context support for nas, oss and s3
This commit is contained in:
@@ -19,7 +19,9 @@ package logger
|
||||
import "context"
|
||||
|
||||
// Key used for ContextSet/Get
|
||||
const contextKey = "reqInfo"
|
||||
type contextKeyType string
|
||||
|
||||
const contextLogKey = contextKeyType("miniolog")
|
||||
|
||||
// KeyVal - appended to ReqInfo.Tags
|
||||
type KeyVal struct {
|
||||
@@ -48,12 +50,12 @@ func (r *ReqInfo) AppendTags(key string, val string) {
|
||||
|
||||
// ContextSet sets ReqInfo in the context.
|
||||
func ContextSet(ctx context.Context, req *ReqInfo) context.Context {
|
||||
return context.WithValue(ctx, contextKey, req)
|
||||
return context.WithValue(ctx, contextLogKey, req)
|
||||
}
|
||||
|
||||
// ContextGet returns ReqInfo if set.
|
||||
func ContextGet(ctx context.Context) *ReqInfo {
|
||||
r, ok := ctx.Value(contextKey).(*ReqInfo)
|
||||
r, ok := ctx.Value(contextLogKey).(*ReqInfo)
|
||||
if ok {
|
||||
return r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user