summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Logger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/Logger.cpp')
-rw-r--r--clang-tools-extra/clangd/Logger.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/clang-tools-extra/clangd/Logger.cpp b/clang-tools-extra/clangd/Logger.cpp
index 0448c6f5b6d..2c0c6f9974a 100644
--- a/clang-tools-extra/clangd/Logger.cpp
+++ b/clang-tools-extra/clangd/Logger.cpp
@@ -9,11 +9,25 @@
#include "Logger.h"
-using namespace clang::clangd;
+namespace clang {
+namespace clangd {
-EmptyLogger &EmptyLogger::getInstance() {
- static EmptyLogger Logger;
- return Logger;
+namespace {
+Logger *L = nullptr;
+} // namespace
+
+LoggingSession::LoggingSession(clangd::Logger &Instance) {
+ assert(!L);
+ L = &Instance;
+}
+
+LoggingSession::~LoggingSession() { L = nullptr; }
+
+void log(const Context &Ctx, const llvm::Twine &Message) {
+ if (!L)
+ return;
+ L->log(Ctx, Message);
}
-void EmptyLogger::log(const llvm::Twine &Message) {}
+} // namespace clangd
+} // namespace clang
OpenPOWER on IntegriCloud