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

Simon Marchi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 8 08:23:40 PST 2018


simark marked an inline comment as done.
simark added inline comments.


================
Comment at: clangd/Logger.cpp:19
 Logger *L = nullptr;
+bool Verbose_ = false;
 } // namespace
----------------
ilya-biryukov wrote:
> Could we move the flag to implementation of `Logger`?
> I.e.:
> ```
> class Logger {
>   virtual log(const llvm::Twine &Message, bool Verbose);
> };
> 
> // Implementation of top-level log
> void clangd::log(const llvm::Twine &Message) {
>    L->log(Message, /*Verbose=*/false);
>    // should also handle missing Logger by logging into llvm::errs()
> }
> 
> // Implementation of top-level vlog.
> void clangd::vlog(const llvm::Twine &Message) {
>    L->log(Message, /*Verbose=*/true);
>    // should also handle missing Logger by logging into llvm::errs()
> }
> ```
> 
> An implementation of the interface would decide whether to log or not, based on command-line argument.
That's what I thought of doing first.  The issue is that if we don't set a logger with LoggingSession, the log function prints to stderr itself.  So if we don't check the Verbose flag there, the -v flag will have no effect when LoggingSession has not been called (I don't know if it's really a problem or not, since in practice we call it).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44226





More information about the cfe-commits mailing list