Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

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

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();
}
}
......
......@@ -27,7 +27,7 @@
#include <KShell>
#include <QList>
#include <QProcess>
#include <QDebug>
#include "libdiscover_debug.h"
AbstractResource::AbstractResource(AbstractResourcesBackend* parent)
: QObject(parent)
......
......@@ -24,7 +24,7 @@
#include <QHash>
#include <QMetaObject>
#include <QMetaProperty>
#include <QDebug>
#include "libdiscover_debug.h"
#include <QTimer>
QDebug operator<<(QDebug debug, const AbstractResourcesBackend::Filters& filters)
......@@ -57,7 +57,7 @@ ResultsStream::ResultsStream(const QString &objectName, const QVector<AbstractRe
ResultsStream::ResultsStream(const QString &objectName)
{
setObjectName(objectName);
QTimer::singleShot(5000, this, [objectName]() { qDebug() << "stream took really long" << objectName; });
QTimer::singleShot(5000, this, [objectName]() { qCDebug(LIBDISCOVER_LOG) << "stream took really long" << objectName; });
}
ResultsStream::~ResultsStream()
......
......@@ -19,7 +19,7 @@
***************************************************************************/
#include "PackageState.h"
#include <QDebug>
#include "libdiscover_debug.h"
PackageState::PackageState(QString name, QString description, bool installed)
: PackageState(name, name, description, installed)
......
......@@ -30,7 +30,7 @@
#include "Transaction/TransactionModel.h"
#include "Category/CategoryModel.h"
#include "utils.h"
#include <QDebug>
#include "libdiscover_debug.h"
#include <QCoreApplication>
#include <QThread>
#include <QAction>
......@@ -97,7 +97,7 @@ void ResourcesModel::addResourcesBackend(AbstractResourcesBackend* backend)
{
Q_ASSERT(!m_backends.contains(backend));
if(!backend->isValid()) {
qWarning() << "Discarding invalid backend" << backend->name();
qCWarning(LIBDISCOVER_LOG) << "Discarding invalid backend" << backend->name();
CategoryModel::global()->blacklistPlugin(backend->name());
backend->deleteLater();
return;
......@@ -130,7 +130,7 @@ void ResourcesModel::callerFetchingChanged()
AbstractResourcesBackend* backend = qobject_cast<AbstractResourcesBackend*>(sender());
if (!backend->isValid()) {
qWarning() << "Discarding invalid backend" << backend->name();
qCWarning(LIBDISCOVER_LOG) << "Discarding invalid backend" << backend->name();
int idx = m_backends.indexOf(backend);
Q_ASSERT(idx>=0);
m_backends.removeAt(idx);
......@@ -207,7 +207,7 @@ void ResourcesModel::registerAllBackends()
DiscoverBackendsFactory f;
const auto backends = f.allBackends();
if(m_initializingBackends==0 && backends.isEmpty()) {
qWarning() << "Couldn't find any backends";
qCWarning(LIBDISCOVER_LOG) << "Couldn't find any backends";
emit allInitialized();
} else {
foreach(AbstractResourcesBackend* b, backends) {
......@@ -272,7 +272,7 @@ AggregatedResultsStream::AggregatedResultsStream(const QSet<ResultsStream*>& str
{
Q_ASSERT(!streams.contains(nullptr));
if (streams.isEmpty()) {
qWarning() << "no streams to aggregate!!";
qCWarning(LIBDISCOVER_LOG) << "no streams to aggregate!!";
QTimer::singleShot(0, this, &AggregatedResultsStream::clear);
}
......@@ -371,7 +371,7 @@ void ResourcesModel::setCurrentApplicationBackend(AbstractResourcesBackend* back
settings.deleteEntry("currentApplicationBackend");
}
qDebug() << "setting currentApplicationBackend" << backend;
qCDebug(LIBDISCOVER_LOG) << "setting currentApplicationBackend" << backend;
m_currentApplicationBackend = backend;
Q_EMIT currentApplicationBackendChanged(backend);
}
......@@ -386,7 +386,7 @@ void ResourcesModel::initApplicationsBackend()
auto idx = kIndexOf(backends, [name](AbstractResourcesBackend* b) { return b->name() == name; });
if (idx<0) {
idx = kIndexOf(backends, [](AbstractResourcesBackend* b) { return b->hasApplications(); });
qDebug() << "falling back applications backend to" << idx;
qCDebug(LIBDISCOVER_LOG) << "falling back applications backend to" << idx;
}
setCurrentApplicationBackend(backends.value(idx, nullptr), false);
}
......@@ -21,7 +21,7 @@
#include "ResourcesProxyModel.h"
#include <QDebug>
#include "libdiscover_debug.h"
#include <QMetaProperty>
#include <utils.h>
......@@ -136,7 +136,7 @@ void ResourcesProxyModel::removeDuplicates(QVector<AbstractResource *>& resource
if (at == storedIds.end()) {
storedIds[appstreamid] = it;
} else {
qWarning() << "We should have sanitized the displayed resources. There is a bug";
qCWarning(LIBDISCOVER_LOG) << "We should have sanitized the displayed resources. There is a bug";
Q_UNREACHABLE();
}
}
......@@ -261,7 +261,7 @@ void ResourcesProxyModel::invalidateFilter()
}
if (m_currentStream) {
qWarning() << "last stream isn't over yet" << m_filters << this;
qCWarning(LIBDISCOVER_LOG) << "last stream isn't over yet" << m_filters << this;
delete m_currentStream;
}
......@@ -421,14 +421,14 @@ QVariant ResourcesProxyModel::roleToValue(AbstractResource* resource, int role)
default: {
QByteArray roleText = roleNames().value(role);
if(Q_UNLIKELY(roleText.isEmpty())) {
qDebug() << "unsupported role" << role;
qCDebug(LIBDISCOVER_LOG) << "unsupported role" << role;
return {};
}
static const QMetaObject* m = &AbstractResource::staticMetaObject;
int propidx = roleText.isEmpty() ? -1 : m->indexOfProperty(roleText.constData());
if(Q_UNLIKELY(propidx < 0)) {
qWarning() << "unknown role:" << role << roleText;
qCWarning(LIBDISCOVER_LOG) << "unknown role:" << role << roleText;
return QVariant();
} else
return m->property(propidx).read(resource);
......
......@@ -26,7 +26,7 @@
#include "AbstractResource.h"
#include "utils.h"
#include <QDateTime>
#include <QDebug>
#include "libdiscover_debug.h"
#include <KLocalizedString>
#include <KFormat>
......@@ -169,7 +169,7 @@ void ResourcesUpdatesModel::message(const QString& msg)
void ResourcesUpdatesModel::prepare()
{
if(isProgressing()) {
qWarning() << "trying to set up a running instance";
qCWarning(LIBDISCOVER_LOG) << "trying to set up a running instance";
return;
}
foreach(AbstractBackendUpdater* upd, m_updaters) {
......
......@@ -20,7 +20,7 @@
#include "SourcesModel.h"
#include <QtGlobal>
#include <QDebug>
#include "libdiscover_debug.h"
#include <QAction>
#include "resources/AbstractResourcesBackend.h"
#include "resources/AbstractSourcesBackend.h"
......
......@@ -25,7 +25,7 @@
#include <Transaction/TransactionModel.h>
#include <KLocalizedString>
#include <QDateTime>
#include <QDebug>
#include "libdiscover_debug.h"
#include <QTimer>
#include <QIcon>
......
Markdown is supported
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