Commit 59500139 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Start to use debug categories

parent eebd044e
......@@ -19,6 +19,7 @@ include(ECMInstallIcons)
include(ECMMarkAsTest)
include(ECMAddTests)
include(GenerateExportHeader)
include(ECMQtDeclareLoggingCategory)
find_package(PkgConfig REQUIRED)
......@@ -88,3 +89,5 @@ set_package_properties(LIBFWUPD PROPERTIES
TYPE OPTIONAL)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
install( FILES discover.categories DESTINATION ${KDE_INSTALL_CONFDIR} )
org.kde.plasma.libdiscover libdiscover IDENTIFIER [LIBDISCOVER_LOG]
......@@ -22,7 +22,7 @@
#include "resources/ResourcesModel.h"
#include "utils.h"
#include <QAction>
#include <QDebug>
#include "libdiscover_debug.h"
ActionsModel::ActionsModel(QObject* parent)
: QAbstractListModel(parent)
......
......@@ -23,7 +23,7 @@
#include <resources/PackageState.h>
#include <resources/AbstractResource.h>
#include <Transaction/TransactionModel.h>
#include <QDebug>
#include "libdiscover_debug.h"
ApplicationAddonsModel::ApplicationAddonsModel(QObject* parent)
: QAbstractListModel(parent)
......
......@@ -36,6 +36,8 @@ set(discovercommon_SRCS
ApplicationAddonsModel.cpp
)
ecm_qt_declare_logging_category(discovercommon_SRCS HEADER libdiscover_debug.h IDENTIFIER LIBDISCOVER_LOG CATEGORY_NAME org.kde.plasma.libdiscover)
if(AppStreamQt_FOUND)
set(discovercommon_SRCS ${discovercommon_SRCS}
appstream/OdrsReviewsBackend.cpp
......
......@@ -22,7 +22,7 @@
#include "Category.h"
#include <QDomNode>
#include <QFile>
#include <QDebug>
#include "libdiscover_debug.h"
#include <QStandardPaths>
#include <DiscoverBackendsFactory.h>
......@@ -34,7 +34,7 @@ QVector<Category*> CategoriesReader::loadCategoriesFile(AbstractResourcesBackend
if (path.isEmpty()) {
auto cat = backend->category();
if (cat.isEmpty())
qWarning() << "Couldn't find a category for " << backend->name();
qCWarning(LIBDISCOVER_LOG) << "Couldn't find a category for " << backend->name();
Category::sortCategories(cat);
return cat;
......@@ -47,7 +47,7 @@ QVector<Category*> CategoriesReader::loadCategoriesPath(const QString& path)
QVector<Category *> ret;
QFile menuFile(path);
if (!menuFile.open(QIODevice::ReadOnly)) {
qWarning() << "couldn't open" << path;
qCWarning(LIBDISCOVER_LOG) << "couldn't open" << path;
return ret;
}
......@@ -56,7 +56,7 @@ QVector<Category*> CategoriesReader::loadCategoriesPath(const QString& path)
int line;
bool correct = menuDocument.setContent(&menuFile, &error, &line);
if(!correct)
qWarning() << "error while parsing the categories file:" << error << " at: " << path << ':' << line;
qCWarning(LIBDISCOVER_LOG) << "error while parsing the categories file:" << error << " at: " << path << ':' << line;
QDomElement root = menuDocument.documentElement();
......
......@@ -25,7 +25,7 @@
#include <klocalizedstring.h>
#include <QFile>
#include <QStandardPaths>
#include <QDebug>
#include "libdiscover_debug.h"
#include <utils.h>
Category::Category(QSet<QString> pluginName, QObject* parent)
......@@ -55,7 +55,7 @@ void Category::parseData(const QString& path, const QDomNode& data)
{
if(!node.isElement()) {
if(!node.isComment())
qWarning() << "unknown node found at " << QStringLiteral("%1:%2").arg(path).arg(node.lineNumber());
qCWarning(LIBDISCOVER_LOG) << "unknown node found at " << QStringLiteral("%1:%2").arg(path).arg(node.lineNumber());
continue;
}
QDomElement tempElement = node.toElement();
......@@ -71,7 +71,7 @@ void Category::parseData(const QString& path, const QDomNode& data)
if (m_decoration.isRelative()) {
m_decoration = QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("discover/") + tempElement.text()));
if (m_decoration.isEmpty())
qWarning() << "couldn't find category decoration" << tempElement.text();
qCWarning(LIBDISCOVER_LOG) << "couldn't find category decoration" << tempElement.text();
}
} else if (tempElement.tagName() == QLatin1String("Addons")) {
m_isAddons = true;
......@@ -111,7 +111,7 @@ QVector<QPair<FilterType, QString> > Category::parseIncludes(const QDomNode &dat
} else if (tempElement.tagName() == QLatin1String("PkgName")) {
filter.append({ PkgNameFilter, tempElement.text() });
} else {
qWarning() << "unknown" << tempElement.tagName();
qCWarning(LIBDISCOVER_LOG) << "unknown" << tempElement.tagName();
}
node = node.nextSibling();
}
......@@ -191,7 +191,7 @@ void Category::addSubcategory(QVector< Category* >& list, Category* newcat)
|| c->m_isAddons != newcat->m_isAddons
)
{
qWarning() << "the following categories seem to be the same but they're not entirely"
qCWarning(LIBDISCOVER_LOG) << "the following categories seem to be the same but they're not entirely"
<< c->name() << newcat->name() << "--"
<< c->andFilters() << newcat->andFilters() << "--"
<< c->isAddons() << newcat->isAddons();
......
......@@ -22,7 +22,7 @@
#include "CategoryModel.h"
#include "Category.h"
#include "CategoriesReader.h"
#include <QDebug>
#include "libdiscover_debug.h"
#include <QCollator>
#include <utils.h>
#include <resources/ResourcesModel.h>
......
......@@ -22,7 +22,7 @@
#include "resources/AbstractResourcesBackend.h"
#include "resources/ResourcesModel.h"
#include "utils.h"
#include <QDebug>
#include "libdiscover_debug.h"
#include <QStandardPaths>
#include <QDir>
#include <QCommandLineParser>
......@@ -56,15 +56,15 @@ QVector<AbstractResourcesBackend*> DiscoverBackendsFactory::backendForFile(const
{
QPluginLoader* loader = new QPluginLoader(QStringLiteral("discover/") + libname, ResourcesModel::global());
// qDebug() << "trying to load plugin:" << loader->fileName();
// qCDebug(LIBDISCOVER_LOG) << "trying to load plugin:" << loader->fileName();
AbstractResourcesBackendFactory* f = qobject_cast<AbstractResourcesBackendFactory*>(loader->instance());
if(!f) {
qWarning() << "error loading" << libname << loader->errorString() << loader->metaData();
qCWarning(LIBDISCOVER_LOG) << "error loading" << libname << loader->errorString() << loader->metaData();
return {};
}
auto instances = f->newInstance(ResourcesModel::global(), name);
if(instances.isEmpty()) {
qWarning() << "Couldn't find the backend: " << libname << "among" << allBackendNames(false, true);
qCWarning(LIBDISCOVER_LOG) << "Couldn't find the backend: " << libname << "among" << allBackendNames(false, true);
return instances;
}
......@@ -100,7 +100,7 @@ QVector<AbstractResourcesBackend*> DiscoverBackendsFactory::allBackends() const
ret.removeAll(nullptr);
if(ret.isEmpty())
qWarning() << "Didn't find any Discover backend!";
qCWarning(LIBDISCOVER_LOG) << "Didn't find any Discover backend!";
return ret;
}
......
......@@ -20,7 +20,7 @@
#include "Rating.h"
#include <QStringList>
#include <QDebug>
#include "libdiscover_debug.h"
#include <qmath.h>
inline double fastPow(double a, double b) {
......
......@@ -23,7 +23,7 @@
#include <resources/ResourcesModel.h>
#include <resources/AbstractResourcesBackend.h>
#include <resources/AbstractResource.h>
#include <QDebug>
#include "libdiscover_debug.h"
ReviewsModel::ReviewsModel(QObject* parent)
: QAbstractListModel(parent)
......@@ -134,7 +134,7 @@ void ReviewsModel::fetchMore(const QModelIndex& parent)
m_lastPage++;
m_backend->fetchReviews(m_app, m_lastPage);
// qDebug() << "fetching reviews... " << m_lastPage;
// qCDebug(LIBDISCOVER_LOG) << "fetching reviews... " << m_lastPage;
}
void ReviewsModel::addReviews(AbstractResource* app, const QVector<ReviewPtr>& reviews, bool canFetchMore)
......@@ -143,7 +143,7 @@ void ReviewsModel::addReviews(AbstractResource* app, const QVector<ReviewPtr>& r
return;
m_canFetchMore = canFetchMore;
// qDebug() << "reviews arrived..." << m_lastPage << reviews.size();
// qCDebug(LIBDISCOVER_LOG) << "reviews arrived..." << m_lastPage << reviews.size();
if(!reviews.isEmpty()) {
beginInsertRows(QModelIndex(), rowCount(), rowCount()+reviews.size()-1);
......@@ -162,7 +162,7 @@ void ReviewsModel::markUseful(int row, bool useful)
{
Review* r = m_reviews[row].data();
r->setUsefulChoice(useful ? Yes : No);
// qDebug() << "submitting usefulness" << r->applicationName() << r->id() << useful;
// qCDebug(LIBDISCOVER_LOG) << "submitting usefulness" << r->applicationName() << r->id() << useful;
m_backend->submitUsefulness(r, useful);
const QModelIndex ind = index(row, 0, QModelIndex());
emit dataChanged(ind, ind, {UsefulnessTotal, UsefulnessFavorable, UsefulChoice});
......
......@@ -20,7 +20,7 @@
#include "ScreenshotsModel.h"
#include <resources/AbstractResource.h>
#include <QDebug>
#include "libdiscover_debug.h"
// #include <tests/modeltest.h>
ScreenshotsModel::ScreenshotsModel(QObject* parent)
......@@ -51,7 +51,7 @@ void ScreenshotsModel::setResource(AbstractResource* res)
connect(m_resource, &AbstractResource::screenshotsFetched, this, &ScreenshotsModel::screenshotsFetched);
res->fetchScreenshots();
} else
qWarning() << "empty resource!";
qCWarning(LIBDISCOVER_LOG) << "empty resource!";
}
AbstractResource* ScreenshotsModel::resource() const
......
......@@ -19,7 +19,7 @@
***************************************************************************/
#include "AddonList.h"
#include <QDebug>
#include "libdiscover_debug.h"
AddonList::AddonList()
{}
......
......@@ -24,7 +24,7 @@
#include "TransactionModel.h"
#include <KFormat>
#include <KLocalizedString>
#include <QDebug>
#include "libdiscover_debug.h"
Transaction::Transaction(QObject *parent, AbstractResource *resource,
Role role, const AddonList& addons)
......@@ -41,7 +41,7 @@ Transaction::Transaction(QObject *parent, AbstractResource *resource,
Transaction::~Transaction()
{
if(status()<DoneStatus || TransactionModel::global()->contains(this)) {
qWarning() << "destroying Transaction before it's over" << this;
qCWarning(LIBDISCOVER_LOG) << "destroying Transaction before it's over" << this;
TransactionModel::global()->removeTransaction(this);
}
}
......
......@@ -23,7 +23,7 @@
#include "TransactionModel.h"
#include <QMetaProperty>
#include <QDebug>
#include "libdiscover_debug.h"
TransactionListener::TransactionListener(QObject *parent)
: QObject(parent)
......@@ -128,7 +128,7 @@ void TransactionListener::setTransaction(Transaction* trans)
connect(m_transaction, &Transaction::statusChanged, this, &TransactionListener::transactionStatusChanged);
connect(m_transaction, &Transaction::progressChanged, this, &TransactionListener::progressChanged);
connect(m_transaction, &QObject::destroyed, this, [this]() {
qDebug() << "destroyed transaction before finishing";
qCDebug(LIBDISCOVER_LOG) << "destroyed transaction before finishing";
setTransaction(nullptr);
});
setResourceInternal(trans->resource());
......
......@@ -27,6 +27,7 @@
// Own includes
#include "resources/AbstractResource.h"
#include "libdiscover_debug.h"
Q_GLOBAL_STATIC(TransactionModel, globalTransactionModel)
......@@ -174,7 +175,7 @@ void TransactionModel::removeTransaction(Transaction *trans)
trans->deleteLater();
int r = m_transactions.indexOf(trans);
if (r<0) {
qWarning() << "transaction not part of the model" << trans;
qCWarning(LIBDISCOVER_LOG) << "transaction not part of the model" << trans;
return;
}
......
......@@ -25,7 +25,7 @@
#include <QtCore/QStringBuilder>
#include <KLocalizedString>
#include <QDebug>
#include "libdiscover_debug.h"
UpdateItem::UpdateItem(AbstractResource *app)
: m_app(app)
......
......@@ -23,7 +23,7 @@
// Qt includes
#include <QFont>
#include <QTimer>
#include <QDebug>
#include "libdiscover_debug.h"
// KDE includes
#include <KFormat>
......
......@@ -23,7 +23,7 @@
#include <QUrl>
#include <QList>
#include <QDebug>
#include "libdiscover_debug.h"
#include <AppStreamQt/image.h>
#include <AppStreamQt/component.h>
#include <AppStreamQt/release.h>
......@@ -65,7 +65,7 @@ static QPair<QList<QUrl>, QList<QUrl>> fetchScreenshots(const AppStream::Compone
const QUrl thumbnail = AppStreamUtils::imageOfKind(images, AppStream::Image::KindThumbnail);
const QUrl plain = AppStreamUtils::imageOfKind(images, AppStream::Image::KindSource);
if (plain.isEmpty())
qWarning() << "invalid screenshot for" << appdata.name();
qCWarning(LIBDISCOVER_LOG) << "invalid screenshot for" << appdata.name();
screenshots << plain;
thumbnails << (thumbnail.isEmpty() ? plain : thumbnail);
......
......@@ -33,7 +33,7 @@
#include <QCryptographicHash>
#include <QDir>
#include <QDebug>
#include "libdiscover_debug.h"
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
......@@ -83,7 +83,7 @@ void OdrsReviewsBackend::ratingsFetched(KJob *job)
{
m_isFetching = false;
if (job->error()) {
qWarning() << "Failed to fetch ratings " << job->errorString();
qCWarning(LIBDISCOVER_LOG) << "Failed to fetch ratings " << job->errorString();
} else {
parseRatings();
}
......@@ -181,7 +181,7 @@ void OdrsReviewsBackend::reviewsFetched()
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
if (reply->error() != QNetworkReply::NoError) {
qWarning() << "error fetching reviews:" << reply->errorString();
qCWarning(LIBDISCOVER_LOG) << "error fetching reviews:" << reply->errorString();
m_isFetching = false;
return;
}
......@@ -241,9 +241,9 @@ void OdrsReviewsBackend::usefulnessSubmitted()
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
if (reply->error() == QNetworkReply::NoError) {
qWarning() << "Usefullness submitted";
qCWarning(LIBDISCOVER_LOG) << "Usefullness submitted";
} else {
qWarning() << "Failed to submit usefulness: " << reply->errorString();
qCWarning(LIBDISCOVER_LOG) << "Failed to submit usefulness: " << reply->errorString();
}
}
......@@ -285,7 +285,7 @@ void OdrsReviewsBackend::submitReview(AbstractResource *res, const QString &summ
void OdrsReviewsBackend::reviewSubmitted(QNetworkReply *reply)
{
if (reply->error() == QNetworkReply::NoError) {
qWarning() << "Review submitted";
qCWarning(LIBDISCOVER_LOG) << "Review submitted";
AbstractResource *resource = qobject_cast<AbstractResource*>(reply->request().originatingObject());
const QJsonArray array = {resource->getMetadata(QStringLiteral("ODRS::review_map")).toObject()};
const QJsonDocument document(array);
......@@ -294,7 +294,7 @@ void OdrsReviewsBackend::reviewSubmitted(QNetworkReply *reply)
file.remove();
parseReviews(document, resource);
} else {
qWarning() << "Failed to submit review: " << reply->errorString();
qCWarning(LIBDISCOVER_LOG) << "Failed to submit review: " << reply->errorString();
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment