Skip to content

Commit

Permalink
Added color for log warnings and errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Glowacki committed Dec 1, 2023
1 parent 699c276 commit 8762b3f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
20 changes: 15 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,27 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
}
else
{
switch (type) {
QString h_msg(msg);
switch (type)
{
case QtDebugMsg:
//h_msg = "<span style=\"color : green; \">" + msg + "</span>\r";
h_msg.replace("\033[1;31mError: \033[0;m", "<span style=\"color : red; font-weight: bold; \">Error: </span>");
h_msg.replace("\033[1;33mWarning: \033[0;m", "<span style=\"color : yellow; font-weight: bold; \">Warning: </span>");
h_msg.replace("\n", "<br />");
uProbeX::log_textedit->append(h_msg);
break;
case QtWarningMsg:
h_msg = "<span style=\"color : yellow; \">" + msg + "</span><br />";
uProbeX::log_textedit->append(h_msg);
break;
case QtCriticalMsg:
// redundant check, could be removed, or the
// upper if statement could be removed
if (uProbeX::log_textedit != nullptr)
uProbeX::log_textedit->append(msg);
h_msg = "<span style=\"color : red; \">" + msg + "</span><br />";
uProbeX::log_textedit->append(h_msg);
break;
case QtFatalMsg:
abort();
break;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/mvc/MapsH5Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ void MapsH5Model::loadAllRoiMaps()
rois[i] = jsonRoi;
resave = true;
}
else
{
logW << "Failed to load roi spectra for " << _dir.absolutePath().toStdString() << "\n";
}
}
_map_rois[mroi.name] = mroi;
}
Expand Down
26 changes: 21 additions & 5 deletions src/mvc/UpgradeRoiDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ void UpgradeRoiDialog::runProcessing()
int i = 0;
for (auto& itr : _roi_fileinfo_list)
{
i++;
_progressBarFiles->setValue(i);
QCoreApplication::processEvents();
MapsH5Model model;
QString hdf_filename;
Expand All @@ -173,6 +171,8 @@ void UpgradeRoiDialog::runProcessing()
break;
}
}
i++;
_progressBarFiles->setValue(i);
}

_progressBarFiles->setValue(proc_total);
Expand Down Expand Up @@ -229,13 +229,25 @@ bool UpgradeRoiDialog::_load_v9_rois(QString fname, MapsH5Model* model, QString
// check V9 ROI's first
// get 4 numbers in dataset name to ref roi's
QRegularExpression re("[0-9][0-9][0-9][0-9]");
QRegularExpression axo_re("axo_std");

QRegularExpressionMatch match = re.match(fname);
if (match.hasMatch())
QRegularExpressionMatch axo_match = axo_re.match(fname);
if (match.hasMatch() || axo_match.hasMatch())
{
QStringList matched_tests = match.capturedTexts();
QString dataset_num = matched_tests.first();
QString dataset_num;
if (match.hasMatch())
{
QStringList matched_tests = match.capturedTexts();
dataset_num = matched_tests.first();
}
if (axo_match.hasMatch())
{
dataset_num = axo_match.capturedTexts().first();
}
QRegularExpression re2(dataset_num);


for (auto& itr : _h5_fileinfo_list)
{
QRegularExpressionMatch match2 = re2.match(itr.first);
Expand Down Expand Up @@ -296,6 +308,10 @@ bool UpgradeRoiDialog::_load_v9_rois(QString fname, MapsH5Model* model, QString
}
}
}
else
{
logW << "Cound not match regular expression [0-9][0-9][0-9][0-9] with filename " << fname.toStdString() << "\n";
}
return false;
}

Expand Down

0 comments on commit 8762b3f

Please sign in to comment.