From f52d530b06dc67768d822ec4a14d88e85d52416b Mon Sep 17 00:00:00 2001 From: Kirill Nikolaev Date: Tue, 10 Oct 2023 15:28:20 +0200 Subject: [PATCH] std/grpc: Export SerializeMessage. Can be reused for Connect-Go. --- std/grpc/logging/logging.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/std/grpc/logging/logging.go b/std/grpc/logging/logging.go index 1171dbd40..2687f111d 100644 --- a/std/grpc/logging/logging.go +++ b/std/grpc/logging/logging.go @@ -61,13 +61,13 @@ func (interceptor) unary(ctx context.Context, req interface{}, info *grpc.UnaryS loggable := !slices.Contains(skipLogging, strings.TrimPrefix(info.FullMethod, "/")) if loggable { - makeNewEvent(ctx, logger.Info().Str("kind", "grpclog").Str("what", "request")).Str("request_body", serializeMessage(req)).Send() + makeNewEvent(ctx, logger.Info().Str("kind", "grpclog").Str("what", "request")).Str("request_body", SerializeMessage(req)).Send() } resp, err := handler(logger.WithContext(ctx), req) if loggable { if err == nil { - logger.Info().Str("kind", "grpclog").Dur("took", time.Since(rdata.Started)).Str("what", "response").Str("response_body", serializeMessage(resp)).Send() + logger.Info().Str("kind", "grpclog").Dur("took", time.Since(rdata.Started)).Str("what", "response").Str("response_body", SerializeMessage(resp)).Send() } else { logger.Info().Str("kind", "grpclog").Dur("took", time.Since(rdata.Started)).Str("what", "response").Err(err).Send() } @@ -193,7 +193,7 @@ func Prepare(ctx context.Context, deps ExtensionDeps) error { return nil } -func serializeMessage(msg interface{}) string { +func SerializeMessage(msg interface{}) string { if msg == nil { return "" }