Use print-utils to print some debug messages.

This commit is contained in:
Gerhard Hoffmann 2023-08-11 10:52:31 +02:00
parent 04d5061d79
commit 6c4b02cb56

View File

@ -23,6 +23,7 @@
#include "ismas/ismas_client.h" #include "ismas/ismas_client.h"
#include "progress_event.h" #include "progress_event.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "utils.h"
QString const Worker::UPDATE_STEP_OK(" [ ok]"); QString const Worker::UPDATE_STEP_OK(" [ ok]");
QString const Worker::UPDATE_STEP_DONE(" [done]"); QString const Worker::UPDATE_STEP_DONE(" [done]");
@ -93,7 +94,7 @@ Worker::Worker(hwinf *hw,
int cnt = 0; int cnt = 0;
while (!m_workerThread.isRunning()) { while (!m_workerThread.isRunning()) {
if (++cnt > 5) { if (++cnt > 5) {
qCritical() << "starting worker thread FAILED"; Utils::printCriticalErrorMsg("starting worker thread FAILED");
return; return;
} }
QThread::sleep(1); QThread::sleep(1);
@ -106,7 +107,7 @@ Worker::~Worker() {
while (!m_workerThread.isFinished()) { while (!m_workerThread.isFinished()) {
if (!m_workerThread.wait(1000)) { if (!m_workerThread.wait(1000)) {
if (++cnt > 5) { if (++cnt > 5) {
qCritical() << "stopping worker thread FAILED"; Utils::printCriticalErrorMsg("stopping worker thread FAILED");
return; return;
} }
} }
@ -565,15 +566,11 @@ bool Worker::customerEnvironment() {
setProgress(progress); setProgress(progress);
emit showErrorMessage("cust-env", emit showErrorMessage("cust-env",
QString("Checkout ") + m_customerRepository + " failed"); QString("Checkout ") + m_customerRepository + " failed");
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(QString("CHECKOUT OF " + m_customerRepository + "FAILED"));
qCritical() << "CHECKOUT OF" << m_customerRepository << "FAILED";
qCritical() << QString(80, '*');
} }
} else { } else {
emit showErrorMessage("cust-env", m_customerRepository + " does not exist"); emit showErrorMessage("cust-env", m_customerRepository + " does not exist");
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(m_customerRepository + " DOES NOT EXIST");
qCritical() << m_customerRepository << "DOES NOT EXIST";
qCritical() << QString(80, '*');
} }
setProgress(100); setProgress(100);
@ -600,9 +597,7 @@ bool Worker::filesToUpdate() {
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE); emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE);
m_filesToUpdate = changedFileNames.value(); m_filesToUpdate = changedFileNames.value();
qInfo() << QString(80, '*'); Utils::printInfoMsg("FILES-TO-UPDATE " + m_filesToUpdate.join(','));
qInfo() << "FILES-TO-UPDATE" << m_filesToUpdate;
qInfo() << QString(80, '*');
int const size = m_filesToUpdate.size(); int const size = m_filesToUpdate.size();
if (size > 1) { if (size > 1) {
@ -617,17 +612,11 @@ bool Worker::filesToUpdate() {
return true; return true;
} }
emit showErrorMessage("files to update", "pulling files failed"); emit showErrorMessage("files to update", "pulling files failed");
Utils::printCriticalErrorMsg("PULLING FILES FAILED");
qCritical() << QString(80, '*');
qCritical() << "PULLING FILES FAILED";
qCritical() << QString(80, '*');
} else { } else {
emit showErrorMessage("files to update", "no files to update (checked-in any files?)"); emit showErrorMessage("files to update", "no files to update (checked-in any files?)");
Utils::printCriticalErrorMsg("NO FILES TO UPDATE (CHECKED IN ANY FILES?)");
qCritical() << QString(80, '*');
qCritical() << "NO FILES TO UPDATE (CHECKED IN ANY FILES?)";
qCritical() << QString(80, '*');
} }
setProgress(progress + 30); setProgress(progress + 30);
} else { } else {
@ -639,9 +628,9 @@ bool Worker::filesToUpdate() {
QString("no changes in ") + m_customerRepository + QString("no changes in ") + m_customerRepository +
" (checked-in any files?)"); " (checked-in any files?)");
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg("NO CHANGES IN "
qCritical() << "NO CHANGES IN" << m_customerRepository << "(CHECKED IN ANY FILES?)"; + m_customerRepository
qCritical() << QString(80, '*'); + " (CHECKED IN ANY FILES?)");
} }
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL); emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);
@ -655,11 +644,8 @@ bool Worker::updateFiles(quint8 percent) {
startProgressLoop(); startProgressLoop();
for (int i = 0; i < m_filesToUpdate.size(); ++i) { for (int i = 0; i < m_filesToUpdate.size(); ++i) {
QString fName = m_filesToUpdate.at(i); QString const fName = m_filesToUpdate.at(i);
Utils::printInfoMsg(QString("FNAME ") + fName);
qInfo() << QString(80, '*');
qInfo() << "FNAME" << fName;
qInfo() << QString(80, '*');
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) { if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
emit appendText("\n( ) Update opkg pakets ..."); emit appendText("\n( ) Update opkg pakets ...");
@ -716,14 +702,10 @@ bool Worker::updateFiles(quint8 percent) {
bool ret = true; bool ret = true;
if (filesToDownload.size() > 0) { if (filesToDownload.size() > 0) {
qInfo() << QString(80, '*'); Utils::printInfoMsg(QString("FILES_TO_DOWNLOAD_TO_PSA_HW ") + filesToDownload.join(','));
qInfo() << "FILES_TO_WORK_ON" << filesToDownload;
qInfo() << QString(80, '*');
ret = m_update->doUpdate(m_displayIndex, filesToDownload); ret = m_update->doUpdate(m_displayIndex, filesToDownload);
} else { } else {
qInfo() << QString(80, '*'); Utils::printCriticalErrorMsg("NO FILES_TO_DOWNLOAD_TO_PSA_HW");
qInfo() << "NO FILES_TO_WORK_ON";
qInfo() << QString(80, '*');
} }
return ret; return ret;
@ -762,12 +744,9 @@ bool Worker::syncCustomerRepositoryAndFS() {
for (int i = 0; i < result.size(); ++i) { for (int i = 0; i < result.size(); ++i) {
qInfo() << result.at(i); qInfo() << result.at(i);
} }
qInfo() << "SUCCESS";
} else { } else {
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
qCritical() << "CMD" << cmd << "FAILED"; + c.getCommandResult());
qCritical() << c.getCommandResult().split('\n');
qCritical() << QString(80, '*');
error = true; error = true;
} }
} }
@ -883,17 +862,13 @@ bool Worker::executeOpkgCommand(QString opkgCommand) {
Command c(opkgCommand); Command c(opkgCommand);
if (c.execute(m_workingDirectory)) { if (c.execute(m_workingDirectory)) {
QString const r = c.getCommandResult(); QString const r = c.getCommandResult();
qInfo() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS, Utils::printInfoMsg(QString("EXECUTE OPKG COMMAND %1 OK: %2")
QString("EXECUTE OPKG COMMAND %1 OK: %2")
.arg(opkgCommand) .arg(opkgCommand)
.arg(c.getCommandResult())); .arg(c.getCommandResult()));
return true; return true;
} else { } else {
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(QString("EXECUTE OPKG COMMAND %1 FAILED")
qCritical() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE, .arg(opkgCommand));
QString("EXECUTE OPKG COMMAND %1 FAILED")
.arg(opkgCommand));
qCritical() << QString(80, '*');
} }
return false; return false;
} }