[clangd] Use buffered llvm::errs() in the clangd binary.
authorEric Liu <ioeric@google.com>
Tue, 28 Aug 2018 13:15:50 +0000 (13:15 +0000)
committerEric Liu <ioeric@google.com>
Tue, 28 Aug 2018 13:15:50 +0000 (13:15 +0000)
Summary: Unbuffered stream can cause significant (non-deterministic) latency for the logger.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D51349

llvm-svn: 340822

clang-tools-extra/clangd/tool/ClangdMain.cpp

index 39f2185..f22dd35 100644 (file)
@@ -259,6 +259,9 @@ int main(int argc, char *argv[]) {
   if (Tracer)
     TracingSession.emplace(*Tracer);
 
+  // Use buffered stream to stderr (we still flush each log message). Unbuffered
+  // stream can cause significant (non-deterministic) latency for the logger.
+  llvm::errs().SetBuffered();
   JSONOutput Out(llvm::outs(), llvm::errs(), LogLevel,
                  InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,
                  PrettyPrint);