[skip e2e] Add comment for logutil (#14666)

Signed-off-by: shaoyue.chen <shaoyue.chen@zilliz.com>
pull/14688/head
shaoyue 2021-12-31 14:25:52 +08:00 committed by GitHub
parent 18d36d78d2
commit edfad4044e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -151,6 +151,7 @@ type logKey int
const logCtxKey logKey = iota
// WithField adds given kv field to the logger in ctx
func WithField(ctx context.Context, key string, value string) context.Context {
logger := log.L()
if ctxLogger, ok := ctx.Value(logCtxKey).(*zap.Logger); ok {
@ -160,6 +161,7 @@ func WithField(ctx context.Context, key string, value string) context.Context {
return context.WithValue(ctx, logCtxKey, logger.With(zap.String(key, value)))
}
// WithReqID adds given reqID field to the logger in ctx
func WithReqID(ctx context.Context, reqID int64) context.Context {
logger := log.L()
if ctxLogger, ok := ctx.Value(logCtxKey).(*zap.Logger); ok {
@ -169,6 +171,7 @@ func WithReqID(ctx context.Context, reqID int64) context.Context {
return context.WithValue(ctx, logCtxKey, logger.With(zap.Int64("reqID", reqID)))
}
// WithModule adds given module field to the logger in ctx
func WithModule(ctx context.Context, module string) context.Context {
logger := log.L()
if ctxLogger, ok := ctx.Value(logCtxKey).(*zap.Logger); ok {