Skip to content

Commit 56b0b28

Browse files
muirdmstamblerre
authored andcommitted
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
1 parent bdebc07 commit 56b0b28

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/lsp/cache/load.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *snapshot) load(ctx context.Context, scope source.Scope) ([]*metadata, e
6262
if err == context.Canceled {
6363
return nil, errors.Errorf("no metadata for %s: %v", uri, err)
6464
}
65-
log.Print(ctx, "go/packages.Load", tag.Of("packages", len(pkgs)))
65+
log.Print(ctx, "go/packages.Load", tag.Of("query", query), tag.Of("packages", len(pkgs)))
6666
if len(pkgs) == 0 {
6767
if err == nil {
6868
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
120120
func (s *snapshot) updateMetadata(ctx context.Context, uri source.Scope, pkgs []*packages.Package, cfg *packages.Config) ([]*metadata, error) {
121121
var results []*metadata
122122
for _, pkg := range pkgs {
123-
log.Print(ctx, "go/packages.Load", tag.Of("package", pkg.PkgPath), tag.Of("files", pkg.CompiledGoFiles))
123+
if _, isDir := uri.(source.DirectoryURI); !isDir || s.view.Options().VerboseOutput {
124+
log.Print(ctx, "go/packages.Load", tag.Of("package", pkg.PkgPath), tag.Of("files", pkg.CompiledGoFiles))
125+
}
124126

125127
// Set the metadata for this package.
126128
if err := s.updateImports(ctx, packagePath(pkg.PkgPath), pkg, cfg, map[packageID]struct{}{}); err != nil {

0 commit comments

Comments
 (0)