11#include <llvm/Support/Chrono.h>
12#include <llvm/Support/Error.h>
13#include <llvm/Support/FormatVariadic.h>
14#include <llvm/Support/raw_ostream.h>
16#include <boost/interprocess/sync/named_mutex.hpp>
17#include <boost/interprocess/sync/scoped_lock.hpp>
38 const llvm::formatv_object_base &Message) {
40 L->log(Level,
Fmt, Message);
43 std::lock_guard<std::mutex>
Guard(
Mu);
44 llvm::errs() << Message <<
"\n";
57 const llvm::formatv_object_base &Message) {
58 using namespace boost::interprocess;
61 llvm::sys::TimePoint<>
Timestamp = std::chrono::system_clock::now();
62 std::lock_guard _(LogsLock);
64 Logs << llvm::formatv(
"{0}[{1:%H:%M:%S.%L}] {2}: {3}\n",
indicator(
Level),
71class SimpleStringError :
public llvm::ErrorInfo<SimpleStringError> {
76 SimpleStringError(std::error_code EC, std::string &&Message)
77 : EC(EC), Message(std::
move(Message)) {}
78 void log(llvm::raw_ostream &
OS)
const override {
OS << Message; }
79 std::string message()
const override {
return Message; }
80 std::error_code convertToErrorCode()
const override {
return EC; }
83char SimpleStringError::ID;
88 return llvm::make_error<SimpleStringError>(EC, std::move(
Msg));
92 : MinLevel(MinLevel), Logs(Logs) {}
Interface to allow custom logging in clangd.
static char indicator(Level L)
LoggingSession(Logger &Instance)
void log(Level, const char *Fmt, const llvm::formatv_object_base &Message) override
Write a line to the logging stream.
StreamLogger(llvm::raw_ostream &Logs, Logger::Level MinLevel)
void logImpl(Logger::Level, const char *Fmt, const llvm::formatv_object_base &)
const char * debugType(const char *Filename)
llvm::Error error(std::error_code, std::string &&)
Whether current platform treats paths case insensitively.
bool fromJSON(const llvm::json::Value &, URIForFile &, llvm::json::Path)
void log(const char *Fmt, Ts &&...Vals)