Skip to content

Commit

Permalink
fix(logging.go): changing marshaler for JSON logging to use gogo (#4319)
Browse files Browse the repository at this point in the history
* fix(logging.go): changing marshaler for JSON logging to use gogo

grpc-gateway json marshaler breaks with gogo protos

#4117

* Retrigger CI pipeline
  • Loading branch information
igaskin committed Sep 14, 2020
1 parent f215233 commit 4e6d8cc
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions util/grpc/logging.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package grpc

import (
"bytes"
"encoding/json"
"fmt"

"github.com/gogo/protobuf/proto"
grpc_logging "github.com/grpc-ecosystem/go-grpc-middleware/logging"
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
ctx_logrus "github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
Expand All @@ -31,11 +29,11 @@ type jsonpbMarshalleble struct {
}

func (j *jsonpbMarshalleble) MarshalJSON() ([]byte, error) {
b := &bytes.Buffer{}
if err := grpc_logrus.JsonPbMarshaller.Marshal(b, j.Message); err != nil {
b, err := proto.Marshal(j.Message)
if err != nil {
return nil, fmt.Errorf("jsonpb serializer failed: %v", err)
}
return b.Bytes(), nil
return b, nil
}

type loggingServerStream struct {
Expand Down

0 comments on commit 4e6d8cc

Please sign in to comment.