Context based logging for rbd

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2019-08-22 22:27:23 +05:30
committed by mergify[bot]
parent 81c28d6cb0
commit 38ca08bf65
7 changed files with 188 additions and 303 deletions

View File

@ -116,13 +116,13 @@ func contextIDInjector(ctx context.Context, req interface{}, info *grpc.UnarySer
}
func logGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
util.V(3).Infof(ctx, "GRPC call: %s", info.FullMethod)
util.V(5).Infof(ctx, "GRPC request: %s", protosanitizer.StripSecrets(req))
klog.V(3).Infof(util.Log(ctx, "GRPC call: %s"), info.FullMethod)
klog.V(5).Infof(util.Log(ctx, "GRPC request: %s"), protosanitizer.StripSecrets(req))
resp, err := handler(ctx, req)
if err != nil {
util.Errorf(ctx, "GRPC error: %v", err)
klog.Errorf(util.Log(ctx, "GRPC error: %v"), err)
} else {
util.V(5).Infof(ctx, "GRPC response: %s", protosanitizer.StripSecrets(resp))
klog.V(5).Infof(util.Log(ctx, "GRPC response: %s"), protosanitizer.StripSecrets(resp))
}
return resp, err
}