mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-22 21:10:22 +00:00
rename Key to CtxKey
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
41b701c98c
commit
ed9330d2f6
@ -111,7 +111,7 @@ var id uint64
|
|||||||
|
|
||||||
func contextIDInjector(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
func contextIDInjector(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||||
atomic.AddUint64(&id, 1)
|
atomic.AddUint64(&id, 1)
|
||||||
ctx = context.WithValue(ctx, util.Key, id)
|
ctx = context.WithValue(ctx, util.CtxKey, id)
|
||||||
return handler(ctx, req)
|
return handler(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,12 +20,12 @@ import (
|
|||||||
|
|
||||||
type contextKey string
|
type contextKey string
|
||||||
|
|
||||||
// Key for context based logging
|
// CtxKey for context based logging
|
||||||
var Key = contextKey("ID")
|
var CtxKey = contextKey("ID")
|
||||||
|
|
||||||
// Log helps in context based logging
|
// Log helps in context based logging
|
||||||
func Log(ctx context.Context, format string) string {
|
func Log(ctx context.Context, format string) string {
|
||||||
id := ctx.Value(Key)
|
id := ctx.Value(CtxKey)
|
||||||
if id == nil {
|
if id == nil {
|
||||||
return format
|
return format
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user