diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2017-12-13 12:51:22 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2017-12-13 12:51:22 +0000 |
commit | 940901e8b169b6d797762e8188e96d7d0446cc3d (patch) | |
tree | 8894fb8dd512ee03f9f682a2f115ace6850ab0a7 /clang-tools-extra/clangd/Logger.cpp | |
parent | 845e5dce835d24a30d876411fa3153115141ae89 (diff) | |
download | bcm5719-llvm-940901e8b169b6d797762e8188e96d7d0446cc3d.tar.gz bcm5719-llvm-940901e8b169b6d797762e8188e96d7d0446cc3d.zip |
[clangd] Implemented logging using Context
Reviewers: sammccall, ioeric, hokein
Reviewed By: sammccall
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D40486
llvm-svn: 320576
Diffstat (limited to 'clang-tools-extra/clangd/Logger.cpp')
-rw-r--r-- | clang-tools-extra/clangd/Logger.cpp | 24 |
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 |