aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/languageclient/languageclientinterface.cpp
diff options
context:
space:
mode:
authorMarcus Tillmanns <[email protected]>2022-12-06 10:10:16 +0100
committerMarcus Tillmanns <[email protected]>2022-12-07 10:30:10 +0000
commitbd716a16bbe29aa82ac4e1fd1cee893a588db3d0 (patch)
tree53bffdb812518e0d2156a2ef1f398f906fbb6689 /src/plugins/languageclient/languageclientinterface.cpp
parentd01173313174765aeb02d4e87447ead47902a8de (diff)
languageclient: Write errors to log file
Helps the user to better understand why his language server might have a problem. Change-Id: I9440a28cb5d0d35808b497bcdcd545d7b10597a0 Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/plugins/languageclient/languageclientinterface.cpp')
-rw-r--r--src/plugins/languageclient/languageclientinterface.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/plugins/languageclient/languageclientinterface.cpp b/src/plugins/languageclient/languageclientinterface.cpp
index e83c1accd93..38d9db03ecf 100644
--- a/src/plugins/languageclient/languageclientinterface.cpp
+++ b/src/plugins/languageclient/languageclientinterface.cpp
@@ -3,8 +3,6 @@
#include "languageclientinterface.h"
-#include "languageclientsettings.h"
-
#include <QLoggingCategory>
using namespace LanguageServerProtocol;
@@ -77,6 +75,13 @@ void BaseClientInterface::parseCurrentMessage()
m_currentMessage = BaseMessage();
}
+StdIOClientInterface::StdIOClientInterface()
+ : m_logFile("lspclient.XXXXXX.log")
+{
+ m_logFile.setAutoRemove(false);
+ m_logFile.open();
+}
+
StdIOClientInterface::~StdIOClientInterface()
{
delete m_process;
@@ -96,10 +101,14 @@ void StdIOClientInterface::startImpl()
this, &StdIOClientInterface::readOutput);
connect(m_process, &QtcProcess::started, this, &StdIOClientInterface::started);
connect(m_process, &QtcProcess::done, this, [this] {
+ m_logFile.flush();
if (m_process->result() != ProcessResult::FinishedWithSuccess)
- emit error(m_process->exitMessage());
+ emit error(QString("%1 (see logs in \"%2\")")
+ .arg(m_process->exitMessage())
+ .arg(m_logFile.fileName()));
emit finished();
});
+ m_logFile.write(QString("Starting server: %1\nOutput:\n\n").arg(m_cmd.toUserOutput()).toUtf8());
m_process->setCommand(m_cmd);
m_process->setWorkingDirectory(m_workingDirectory);
if (m_env.isValid())
@@ -137,8 +146,12 @@ void StdIOClientInterface::sendData(const QByteArray &data)
void StdIOClientInterface::readError()
{
QTC_ASSERT(m_process, return);
+
+ const QByteArray stdErr = m_process->readAllStandardError();
+ m_logFile.write(stdErr);
+
qCDebug(LOGLSPCLIENTV) << "StdIOClient std err:\n";
- qCDebug(LOGLSPCLIENTV).noquote() << m_process->readAllStandardError();
+ qCDebug(LOGLSPCLIENTV).noquote() << stdErr;
}
void StdIOClientInterface::readOutput()