Move logging from QDebug to QCDebug and introduce LoggingCategories.

This commit is contained in:
Lukas Brübach 2025-01-17 11:37:30 +01:00
parent 92a903b035
commit 710f7b0f07
63 changed files with 262 additions and 123 deletions

View file

@ -61,7 +61,7 @@ void DlgEditAvatar::actBrowse()
imgReader.setDecideFormatFromContent(true);
imgReader.setFileName(fileName);
if (!imgReader.read(&image)) {
qDebug() << "Avatar image loading failed for file:" << fileName;
qCDebug(DlgEditAvatarLog) << "Avatar image loading failed for file:" << fileName;
imageLabel->setText(tr("Invalid image chosen."));
return;
}

View file

@ -4,6 +4,9 @@
#include <QComboBox>
#include <QDialog>
#include <QLineEdit>
#include <QLoggingCategory>
inline Q_LOGGING_CATEGORY(DlgEditAvatarLog, "dlg_edit_avatar.debug")
class QLabel;
class QPushButton;

View file

@ -198,7 +198,7 @@ QString GeneralSettingsPage::languageName(const QString &lang)
QString appNameHint = translationPrefix + "_" + lang;
bool appTranslationLoaded = qTranslator.load(appNameHint, translationPath);
if (!appTranslationLoaded) {
qDebug() << "Unable to load" << translationPrefix << "translation" << appNameHint << "at" << translationPath;
qCDebug(DlgSettingsLog) << "Unable to load" << translationPrefix << "translation" << appNameHint << "at" << translationPath;
}
return qTranslator.translate("i18n", DEFAULT_LANG_NAME);
@ -1535,7 +1535,7 @@ void DlgSettings::closeEvent(QCloseEvent *event)
bool showLoadError = true;
QString loadErrorMessage = tr("Unknown Error loading card database");
LoadStatus loadStatus = CardDatabaseManager::getInstance()->getLoadStatus();
qDebug() << "Card Database load status: " << loadStatus;
qCDebug(DlgSettingsLog) << "Card Database load status: " << loadStatus;
switch (loadStatus) {
case Ok:
showLoadError = false;

View file

@ -8,9 +8,12 @@
#include <QDialog>
#include <QGroupBox>
#include <QLabel>
#include <QLoggingCategory>
#include <QPushButton>
#include <QSpinBox>
inline Q_LOGGING_CATEGORY(DlgSettingsLog, "dlg_settings.debug");
class ShortcutTreeView;
class SearchLineEdit;
class QTreeView;

View file

@ -146,7 +146,7 @@ void DlgTipOfTheDay::updateTip(int tipId)
tipTextContent->setText(contentText);
if (!image->load(imagePath)) {
qDebug() << "Image failed to load from" << imagePath;
qCDebug(DlgTipOfTheDayLog) << "Image failed to load from" << imagePath;
imageLabel->clear();
} else {
int h = std::min(std::max(imageLabel->height(), MIN_TIP_IMAGE_HEIGHT), MAX_TIP_IMAGE_HEIGHT);

View file

@ -5,10 +5,13 @@
#include <QDialog>
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QLoggingCategory>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
inline Q_LOGGING_CATEGORY(DlgTipOfTheDayLog, "dlg_tip_of_the_day.debug");
class QLabel;
class QPushButton;
class QCheckBox;

View file

@ -221,7 +221,7 @@ void DlgUpdate::downloadSuccessful(const QUrl &filepath)
// Try to open the installer. If it opens, quit Cockatrice
if (QDesktopServices::openUrl(filepath)) {
QMetaObject::invokeMethod(static_cast<MainWindow *>(parent()), "close", Qt::QueuedConnection);
qDebug() << "Opened downloaded update file successfully - closing Cockatrice";
qCDebug(DlgUpdateLog) << "Opened downloaded update file successfully - closing Cockatrice";
close();
} else {
setLabel(tr("Error"));

View file

@ -4,8 +4,12 @@
#include "../client/update_downloader.h"
#include <QDialogButtonBox>
#include <QLoggingCategory>
#include <QProgressDialog>
#include <QtNetwork>
inline Q_LOGGING_CATEGORY(DlgUpdateLog, "dlg_update.debug");
class Release;
class DlgUpdate : public QDialog