LanguageClient: log progress duration

Change-Id: I443f6c909b5ba15babf4741937b99d57c5825169
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2022-09-21 11:14:28 +02:00
parent e84db05786
commit c849a1b1e9
2 changed files with 15 additions and 0 deletions

View File

@@ -7,10 +7,14 @@
#include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/progressmanager.h>
#include <languageserverprotocol/progresssupport.h> #include <languageserverprotocol/progresssupport.h>
#include <QTime>
using namespace LanguageServerProtocol; using namespace LanguageServerProtocol;
namespace LanguageClient { namespace LanguageClient {
static Q_LOGGING_CATEGORY(LOGPROGRESS, "qtc.languageclient.progress", QtWarningMsg);
ProgressManager::ProgressManager() ProgressManager::ProgressManager()
{} {}
@@ -69,6 +73,8 @@ void ProgressManager::beginProgress(const ProgressToken &token, const WorkDonePr
Core::FutureProgress *progress = Core::ProgressManager::addTask( Core::FutureProgress *progress = Core::ProgressManager::addTask(
interface->future(), title, languageClientProgressId(token)); interface->future(), title, languageClientProgressId(token));
m_progress[token] = {progress, interface}; m_progress[token] = {progress, interface};
if (LOGPROGRESS().isDebugEnabled())
m_timer[token].start();
reportProgress(token, begin); reportProgress(token, begin);
} }
@@ -101,6 +107,13 @@ void ProgressManager::endProgress(const ProgressToken &token, const WorkDoneProg
} }
progress.progressInterface->setSubtitle(message); progress.progressInterface->setSubtitle(message);
progress.progressInterface->setSubtitleVisibleInStatusBar(!message.isEmpty()); progress.progressInterface->setSubtitleVisibleInStatusBar(!message.isEmpty());
auto timer = m_timer.take(token);
if (timer.isValid()) {
qCDebug(LOGPROGRESS) << QString("%1 took %2")
.arg(progress.progressInterface->title())
.arg(QTime::fromMSecsSinceStartOfDay(timer.elapsed())
.toString(Qt::ISODateWithMs));
}
} }
endProgress(token); endProgress(token);
} }

View File

@@ -5,6 +5,7 @@
#include <coreplugin/progressmanager/futureprogress.h> #include <coreplugin/progressmanager/futureprogress.h>
#include <QElapsedTimer>
#include <QFutureInterface> #include <QFutureInterface>
#include <QPointer> #include <QPointer>
@@ -46,6 +47,7 @@ private:
QMap<LanguageServerProtocol::ProgressToken, LanguageClientProgress> m_progress; QMap<LanguageServerProtocol::ProgressToken, LanguageClientProgress> m_progress;
QMap<LanguageServerProtocol::ProgressToken, QString> m_titles; QMap<LanguageServerProtocol::ProgressToken, QString> m_titles;
QMap<LanguageServerProtocol::ProgressToken, QElapsedTimer> m_timer;
}; };
} // namespace LanguageClient } // namespace LanguageClient