internal/lsp: suppress info and default logging unless a verbose flag is supplied

Change-Id: Ib4bf2a47cad4151b4b64d922855013b22b4fbb15
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176641
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/internal/lsp/cmd/cmd.go b/internal/lsp/cmd/cmd.go
index e4a8da5..f1baea7 100644
--- a/internal/lsp/cmd/cmd.go
+++ b/internal/lsp/cmd/cmd.go
@@ -47,6 +47,9 @@
 
 	// Support for remote lsp server
 	Remote string `flag:"remote" help:"*EXPERIMENTAL* - forward all commands to a remote lsp"`
+
+	// Enable verbose logging
+	Verbose bool `flag:"v" help:"Verbose output"`
 }
 
 // Name implements tool.Application returning the binary name.
@@ -225,11 +228,17 @@
 	case protocol.Warning:
 		log.Print("Warning:", p.Message)
 	case protocol.Info:
-		log.Print("Info:", p.Message)
+		if c.app.Verbose {
+			log.Print("Info:", p.Message)
+		}
 	case protocol.Log:
-		log.Print("Log:", p.Message)
+		if c.app.Verbose {
+			log.Print("Log:", p.Message)
+		}
 	default:
-		log.Print(p.Message)
+		if c.app.Verbose {
+			log.Print(p.Message)
+		}
 	}
 	return nil
 }