From 56b0b28a00f70e5545e8b1caf3ceb7c197d1924a Mon Sep 17 00:00:00 2001 From: Muir Manders Date: Tue, 10 Dec 2019 11:29:58 -0800 Subject: [PATCH] internal/lsp: put verbose go/packages output behind verboseOutput flag On startup gopls runs go/packages over the entire workspace. The log message in question outputs each package found along with all the package's filenames. Obviously in a large project this produces an incredible amount of output. Fix by putting the log message behind the "verboseOutput" flag when invoking go/packages in the "dir/..." mode. I also added the go/packages "query" string to the once-per-go-packages-call log message so it is more useful. Change-Id: I651419e34a855325056bca6720eda8671f7d5fa8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/210739 Run-TryBot: Muir Manders TryBot-Result: Gobot Gobot Reviewed-by: Rebecca Stambler --- internal/lsp/cache/load.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/lsp/cache/load.go b/internal/lsp/cache/load.go index 2b5c16bf0f..5b55f14744 100644 --- a/internal/lsp/cache/load.go +++ b/internal/lsp/cache/load.go @@ -62,7 +62,7 @@ func (s *snapshot) load(ctx context.Context, scope source.Scope) ([]*metadata, e if err == context.Canceled { return nil, errors.Errorf("no metadata for %s: %v", uri, err) } - log.Print(ctx, "go/packages.Load", tag.Of("packages", len(pkgs))) + log.Print(ctx, "go/packages.Load", tag.Of("query", query), tag.Of("packages", len(pkgs))) if len(pkgs) == 0 { if err == nil { err = errors.Errorf("no packages found for query %s", query) @@ -120,7 +120,9 @@ func (c *cache) shouldLoad(ctx context.Context, s *snapshot, originalFH, current func (s *snapshot) updateMetadata(ctx context.Context, uri source.Scope, pkgs []*packages.Package, cfg *packages.Config) ([]*metadata, error) { var results []*metadata for _, pkg := range pkgs { - log.Print(ctx, "go/packages.Load", tag.Of("package", pkg.PkgPath), tag.Of("files", pkg.CompiledGoFiles)) + if _, isDir := uri.(source.DirectoryURI); !isDir || s.view.Options().VerboseOutput { + log.Print(ctx, "go/packages.Load", tag.Of("package", pkg.PkgPath), tag.Of("files", pkg.CompiledGoFiles)) + } // Set the metadata for this package. if err := s.updateImports(ctx, packagePath(pkg.PkgPath), pkg, cfg, map[packageID]struct{}{}); err != nil {