log to stderr to forward to lsp client

This commit is contained in:
Yan Pas 2019-01-19 17:28:01 +03:00
parent 7a79ed92b2
commit 3ae916cbfc

View File

@ -67,11 +67,14 @@ Message::Message(Verbosity verbosity, const char *file, int line)
} }
Message::~Message() { Message::~Message() {
if (!file)
return;
std::lock_guard<std::mutex> lock(mtx); std::lock_guard<std::mutex> lock(mtx);
stream_ << '\n'; stream_ << '\n';
fputs(stream_.str().c_str(), file); if (file) {
fputs(stream_.str().c_str(), file);
fflush(file);
}
fputs(stream_.str().c_str(), stderr);
fflush(stderr); // stderr is redirected to LSP client
if (verbosity_ == Verbosity_FATAL) if (verbosity_ == Verbosity_FATAL)
abort(); abort();
} }