[PATCH] D44226: [clangd] Add -log-lsp-to-stderr option

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 3 04:39:33 PDT 2018


ilya-biryukov added inline comments.


================
Comment at: clangd/ClangdLSPServer.cpp:412
+    llvm::raw_string_ostream OS(Message);
+    OS << "method not found (" << Method << ")";
+    replyError(ErrorCode::MethodNotFound, OS.str());
----------------
malaperle wrote:
> ilya-biryukov wrote:
> > Could we also `log` (i.e. not `vlog`) names of the methods that were handled successfully? To have some context when something crashes and we only have non-verbose logs.
> Wouldn't that mean pretty much logging everything coming in? The idea of this patch it to make it that by default Clangd is not talkative unless there is an error and optionally make it verbose, for troubleshooting.
Logs are also useful to diagnose problems in case something crashes or works incorrectly.
Clang will probably log something when processing any request anyway, logging the method name first will merely give some more context on which request other log messages correspond to.

> The idea of this patch it to make it that by default Clangd is not talkative unless there is an error.
I don't think we use logging this way in clangd. Logs give us a way to make sense of what's happening inside clangd even when there's no error. `vlog` lets us turn off some extremely noisy output that is not useful most of the time.
We have a whole bunch of log statements that don't correspond to errors (e.g. "reusing preamble", "building file with compile command").


================
Comment at: clangd/JSONRPCDispatcher.h:54
+  /// Whether we should log verbosely.
+  const bool Verbose;
+
----------------
This flag should be private.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44226





More information about the cfe-commits mailing list