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