TUN-5570: Only log RPC server events at error level to reduce noise

This commit is contained in:
cthuang 2021-12-20 10:58:06 +00:00 committed by Chung Ting Huang
parent 41b9c22216
commit 8f46065ab5
1 changed files with 5 additions and 2 deletions

View File

@ -155,13 +155,16 @@ func NewRPCServerStream(stream io.ReadWriteCloser, protocol ProtocolSignature) (
} }
func (s *RPCServerStream) Serve(sessionManager tunnelpogs.SessionManager, logger *zerolog.Logger) error { func (s *RPCServerStream) Serve(sessionManager tunnelpogs.SessionManager, logger *zerolog.Logger) error {
rpcTransport := tunnelrpc.NewTransportLogger(logger, rpc.StreamTransport(s)) // RPC logs are very robust, create a new logger that only logs error to reduce noise
rpcLogger := logger.Level(zerolog.ErrorLevel)
rpcTransport := tunnelrpc.NewTransportLogger(&rpcLogger, rpc.StreamTransport(s))
defer rpcTransport.Close() defer rpcTransport.Close()
main := tunnelpogs.SessionManager_ServerToClient(sessionManager) main := tunnelpogs.SessionManager_ServerToClient(sessionManager)
rpcConn := rpc.NewConn( rpcConn := rpc.NewConn(
rpcTransport, rpcTransport,
rpc.MainInterface(main.Client), rpc.MainInterface(main.Client),
tunnelrpc.ConnLog(&rpcLogger),
) )
defer rpcConn.Close() defer rpcConn.Close()
@ -179,7 +182,7 @@ func DetermineProtocol(stream io.Reader) (ProtocolSignature, error) {
case RPCStreamProtocolSignature: case RPCStreamProtocolSignature:
return RPCStreamProtocolSignature, nil return RPCStreamProtocolSignature, nil
default: default:
return ProtocolSignature{}, fmt.Errorf("Unknown signature %v", signature) return ProtocolSignature{}, fmt.Errorf("unknown signature %v", signature)
} }
} }