Skip to content

Commit

Permalink
rpc:log_interceptor.go update log params
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzi committed Jun 8, 2018
1 parent a058d25 commit c8c1a5c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions rpc/log_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
package rpc

import (
"strings"

"github.com/nebulasio/go-nebulas/util/logging"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
Expand All @@ -35,10 +37,18 @@ func loggingStream(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServe
}

func loggingUnary(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
logging.VLog().WithFields(logrus.Fields{
"method": info.FullMethod,
"params": req,
}).Info("Rpc request.")

if strings.Contains(info.FullMethod, "ApiService") {
logging.VLog().WithFields(logrus.Fields{
"method": info.FullMethod,
"params": req,
}).Info("Rpc request.")
} else {
logging.VLog().WithFields(logrus.Fields{
"method": info.FullMethod,
}).Info("Rpc request.")
}

metricsRPCCounter.Mark(1)

return handler(ctx, req)
Expand Down

0 comments on commit c8c1a5c

Please sign in to comment.