diff options
author | Sam McCall <sam.mccall@gmail.com> | 2018-07-11 10:35:11 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2018-07-11 10:35:11 +0000 |
commit | bed5885d9e4f3202d06c11974474a49c56fa397f (patch) | |
tree | 49820a0a7770c18de12ec8bb7857e8b2c6b88974 /clang-tools-extra/clangd/Logger.cpp | |
parent | a042fae6e08d22750b529c3ff685f236bae5141f (diff) | |
download | bcm5719-llvm-bed5885d9e4f3202d06c11974474a49c56fa397f.tar.gz bcm5719-llvm-bed5885d9e4f3202d06c11974474a49c56fa397f.zip |
[clangd] Upgrade logging facilities with levels and formatv.
Summary:
log() is split into four functions:
- elog()/log()/vlog() have different severity levels, allowing filtering
- dlog() is a lazy macro which uses LLVM_DEBUG - it logs to the logger, but
conditionally based on -debug-only flag and is omitted in release builds
All logging functions use formatv-style format strings now, e.g:
log("Could not resolve URI {0}: {1}", URI, Result.takeError());
Existing log sites have been split between elog/log/vlog by best guess.
This includes a workaround for passing Error to formatv that can be
simplified when D49170 or similar lands.
Subscribers: ilya-biryukov, javed.absar, ioeric, MaskRay, jkorous, cfe-commits
Differential Revision: https://reviews.llvm.org/D49008
llvm-svn: 336785
Diffstat (limited to 'clang-tools-extra/clangd/Logger.cpp')
-rw-r--r-- | clang-tools-extra/clangd/Logger.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang-tools-extra/clangd/Logger.cpp b/clang-tools-extra/clangd/Logger.cpp index 08253844725..5ce3351f13e 100644 --- a/clang-tools-extra/clangd/Logger.cpp +++ b/clang-tools-extra/clangd/Logger.cpp @@ -25,9 +25,10 @@ LoggingSession::LoggingSession(clangd::Logger &Instance) { LoggingSession::~LoggingSession() { L = nullptr; } -void log(const llvm::Twine &Message) { +void detail::log(Logger::Level Level, + const llvm::formatv_object_base &Message) { if (L) - L->log(Message); + L->log(Level, Message); else { static std::mutex Mu; std::lock_guard<std::mutex> Guard(Mu); @@ -35,5 +36,13 @@ void log(const llvm::Twine &Message) { } } +const char *detail::debugType(const char *Filename) { + if (const char *Slash = strrchr(Filename, '/')) + return Slash + 1; + if (const char *Backslash = strrchr(Filename, '\\')) + return Backslash + 1; + return Filename; +} + } // namespace clangd } // namespace clang |