Skip to content

Commit

Permalink
internal/lsp/lsprpc: quiet the handshaker during regtests
Browse files Browse the repository at this point in the history
There's a bunch of noise in regtest results related to the LSP forwarder
handshake.

lsprpc.StreamServer was already configurable to disable connection
logging in tests. Use this configuration to also disable handshake
logging.

Change-Id: I4b00e23d1f0bc6dc5fdd1f6f470f0b892c6791bc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/249418
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
  • Loading branch information
findleyr committed Aug 21, 2020
1 parent ed71c57 commit c886c0b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/lsp/lsprpc/lsprpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (s *StreamServer) ServeStream(ctx context.Context, conn jsonrpc2.Conn) erro
ctx = protocol.WithClient(ctx, client)
conn.Go(ctx,
protocol.Handlers(
handshaker(session, executable,
handshaker(session, executable, s.logConnections,
protocol.ServerHandler(server,
jsonrpc2.MethodNotFound))))
if s.logConnections {
Expand Down Expand Up @@ -497,7 +497,7 @@ const (
sessionsMethod = "gopls/sessions"
)

func handshaker(session *cache.Session, goplsPath string, handler jsonrpc2.Handler) jsonrpc2.Handler {
func handshaker(session *cache.Session, goplsPath string, logHandshakes bool, handler jsonrpc2.Handler) jsonrpc2.Handler {
return func(ctx context.Context, reply jsonrpc2.Replier, r jsonrpc2.Request) error {
switch r.Method() {
case handshakeMethod:
Expand All @@ -506,11 +506,15 @@ func handshaker(session *cache.Session, goplsPath string, handler jsonrpc2.Handl
// client.
var req handshakeRequest
if err := json.Unmarshal(r.Params(), &req); err != nil {
log.Printf("Error processing handshake for session %s: %v", session.ID(), err)
if logHandshakes {
log.Printf("Error processing handshake for session %s: %v", session.ID(), err)
}
sendError(ctx, reply, err)
return nil
}
log.Printf("Session %s: got handshake. Logfile: %q, Debug addr: %q", session.ID(), req.Logfile, req.DebugAddr)
if logHandshakes {
log.Printf("Session %s: got handshake. Logfile: %q, Debug addr: %q", session.ID(), req.Logfile, req.DebugAddr)
}
event.Log(ctx, "Handshake session update",
cache.KeyUpdateSession.Of(session),
tag.DebugAddress.Of(req.DebugAddr),
Expand Down

0 comments on commit c886c0b

Please sign in to comment.