github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/client/ctx.go (about) 1 package client 2 3 import ( 4 "context" 5 6 "google.golang.org/grpc/metadata" 7 ) 8 9 const ( 10 logLevelRPCMetaKey = "log_level" 11 clientRequestIDKey = "client_request_id" 12 13 debugLevel = "debug" 14 infoLevel = "info" 15 warnLevel = "warn" 16 errorLevel = "error" 17 ) 18 19 func WithDebugLogLevel(ctx context.Context) context.Context { 20 return metadata.AppendToOutgoingContext(ctx, logLevelRPCMetaKey, debugLevel) 21 } 22 23 func WithInfoLogLevel(ctx context.Context) context.Context { 24 return metadata.AppendToOutgoingContext(ctx, logLevelRPCMetaKey, infoLevel) 25 } 26 27 func WithWarnLogLevel(ctx context.Context) context.Context { 28 return metadata.AppendToOutgoingContext(ctx, logLevelRPCMetaKey, warnLevel) 29 } 30 31 func WithErrorLogLevel(ctx context.Context) context.Context { 32 return metadata.AppendToOutgoingContext(ctx, logLevelRPCMetaKey, errorLevel) 33 } 34 35 func WithClientRequestID(ctx context.Context, reqID string) context.Context { 36 return metadata.AppendToOutgoingContext(ctx, clientRequestIDKey, reqID) 37 }