diff options
author | Ian Cottrell <iancottrell@google.com> | 2020-05-08 17:27:48 -0400 |
---|---|---|
committer | Ian Cottrell <iancottrell@google.com> | 2020-05-11 17:49:55 +0000 |
commit | 01e0872ccf9a4a8d37c0ee5a60345eb47b7b9c31 (patch) | |
tree | 50b42128c0c32480ad9910312a97774d5c6c8f25 /internal/lsp/debug | |
parent | 2212a7e161a54c76aa397a96d267a553b8aeda7c (diff) | |
download | golang-x-tools-01e0872ccf9a4a8d37c0ee5a60345eb47b7b9c31.tar.gz |
internal/event: improve the logging of events
This extracts the printing code from the log writer so it can be re-used
and then changes the loggers in the lsp to use it.
This means that messages that used to look like
date:
message=text
now print as
date: text
which makes the logs a lot easier to read.
Change-Id: I9dfbae47cdc9aeb7d3ca3279e445f39f2e590827
Reviewed-on: https://go-review.googlesource.com/c/tools/+/232989
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'internal/lsp/debug')
-rw-r--r-- | internal/lsp/debug/serve.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/lsp/debug/serve.go b/internal/lsp/debug/serve.go index 64b644790..15c0d3001 100644 --- a/internal/lsp/debug/serve.go +++ b/internal/lsp/debug/serve.go @@ -545,6 +545,8 @@ func (i *Instance) writeMemoryDebug(threshold uint64) error { } func makeGlobalExporter(stderr io.Writer) event.Exporter { + p := export.Printer{} + var pMu sync.Mutex return func(ctx context.Context, ev core.Event, lm label.Map) context.Context { i := GetInstance(ctx) @@ -555,7 +557,9 @@ func makeGlobalExporter(stderr io.Writer) event.Exporter { } // Make sure any log messages without an instance go to stderr. if i == nil { - fmt.Fprintf(stderr, "%v\n", ev) + pMu.Lock() + p.WriteEvent(stderr, ev, lm) + pMu.Unlock() } } ctx = protocol.LogEvent(ctx, ev, lm) |