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"
32 const llvm::formatv_object_base &Message) {
34 L->
log(Level, Fmt, Message);
37 std::lock_guard<std::mutex> Guard(Mu);
38 llvm::errs() << Message <<
"\n";
43 if (
const char *Slash = strrchr(
Filename,
'/'))
45 if (
const char *Backslash = strrchr(
Filename,
'\\'))
51 const llvm::formatv_object_base &Message) {
54 llvm::sys::TimePoint<> Timestamp = std::chrono::system_clock::now();
56 std::lock_guard<std::mutex> Guard(StreamMutex);
57 Logs << llvm::formatv(
"{0}[{1:%H:%M:%S.%L}] {2}\n",
indicator(
Level),
64class SimpleStringError :
public llvm::ErrorInfo<SimpleStringError> {
69 SimpleStringError(std::error_code EC, std::string &&Message)
70 : EC(EC), Message(std::move(Message)) {}
71 void log(llvm::raw_ostream &
OS)
const override {
OS << Message; }
72 std::string message()
const override {
return Message; }
73 std::error_code convertToErrorCode()
const override {
return EC; }
76char SimpleStringError::ID;
81 return llvm::make_error<SimpleStringError>(EC, std::move(Msg));
std::string Filename
Filename as a string.
llvm::raw_string_ostream OS
Interface to allow custom logging in clangd.
virtual void log(Level, const char *Fmt, const llvm::formatv_object_base &Message)=0
Implementations of this method must be thread-safe.
Level
The significance or severity of this message.
static char indicator(Level L)
LoggingSession(clangd::Logger &Instance)
void log(Level, const char *Fmt, const llvm::formatv_object_base &Message) override
Write a line to the logging stream.
const char * debugType(const char *Filename)
void logImpl(Logger::Level, const char *Fmt, const llvm::formatv_object_base &)
llvm::Error error(std::error_code, std::string &&)
void log(const llvm::Twine &Message)
Records a single instant event, associated with the current thread.
void log(const char *Fmt, Ts &&... Vals)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//