From 62237125555c79a389959048128e067a6b1d90a9 Mon Sep 17 00:00:00 2001 From: Pontus Leitzler Date: Sun, 6 Oct 2019 22:41:29 +0200 Subject: [PATCH] internal/lsp: fix lsp trace log format for gopls The -rpc.trace flag in gopls enables logging in "lsp inspector format". Currently sent responses isn't parsed by the lsp inspector so it fails to parse gopls logs. The lsp inspector regexp matcher requires the duration to be prefixed with "took" instead of "in", e.g. "took ms.". This change updates gopls to match the log parser in lsp inspector, see https://github.com/microsoft/language-server-protocol-inspector/blob/9aff7a693924c6bc67d8d30998ee15b32e9f52b1/lsp-inspector/src/logParser/rawLogParser.ts#L88 Change-Id: I3696faf34ba4f0b3d4e205693eaf378941f2f68f Reviewed-on: https://go-review.googlesource.com/c/tools/+/199517 Run-TryBot: Rebecca Stambler Reviewed-by: Rebecca Stambler --- internal/lsp/protocol/log.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/lsp/protocol/log.go b/internal/lsp/protocol/log.go index 431155fe461..1bb5c27fc0f 100644 --- a/internal/lsp/protocol/log.go +++ b/internal/lsp/protocol/log.go @@ -211,7 +211,7 @@ func logIn(outfd io.Writer, data []byte) { } else if v.ID != nil && v.Method == "" && v.Params == nil { sc := maps.server(id, true) elapsed := tm.Sub(sc.start) - fmt.Fprintf(&buf, "Sending response '%s - (%s)' in %dms.\n", + fmt.Fprintf(&buf, "Sending response '%s - (%s)' took %dms.\n", sc.method, id, elapsed/time.Millisecond) if v.Result == nil { fmt.Fprintf(&buf, "Result: {}%s", eor)