Commit 160f1032 authored by Méven Car's avatar Méven Car
Browse files

Add a logging category for the backend

Summary:
To get rid of tons of logs like :
using... PackageKit::Transaction(0x55db7f249ab0) "/14940_dbaecdcb"
using... PackageKit::Transaction(0x55db7f33fba0) "/14940_dbaecdcb"
using... PackageKit::Transaction(0x55db7d97b860) "/14941_ecaeeebe"

Test Plan: builds

Reviewers: apol, ngraham, mlaurent

Reviewed By: apol, mlaurent

Subscribers: mlaurent, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26533
parent 82b421b8
org.kde.plasma.libdiscover libdiscover IDENTIFIER [LIBDISCOVER_LOG]
org.kde.plasma.discover discover IDENTIFIER [DISCOVER_LOG]
org.kde.plasma.libdiscover.backend libdiscover backend IDENTIFIER [LIBDISCOVER_BACKEND_LOG]
......@@ -2,7 +2,9 @@ find_package(KF5 REQUIRED Notifications)
add_subdirectory(runservice)
add_library(packagekit-backend MODULE PackageKitBackend.cpp
#packagekit-backend
set (packagekit-backend_SRCS
PackageKitBackend.cpp
PackageKitResource.cpp
AppPackageKitResource.cpp
PKTransaction.cpp
......@@ -12,7 +14,10 @@ add_library(packagekit-backend MODULE PackageKitBackend.cpp
LocalFilePKResource.cpp
TransactionSet.cpp
pkui.qrc
)
)
ecm_qt_declare_logging_category(packagekit-backend_SRCS HEADER libdiscover_backend_debug.h IDENTIFIER LIBDISCOVER_BACKEND_LOG CATEGORY_NAME org.kde.plasma.libdiscover.backend)
add_library(packagekit-backend MODULE ${packagekit-backend_SRCS})
target_link_libraries(packagekit-backend PRIVATE Discover::Common Qt5::Core PK::packagekitqt5 KF5::ConfigGui KF5::KIOCore KF5::Archive AppStreamQt)
install(TARGETS packagekit-backend DESTINATION ${PLUGIN_INSTALL_DIR}/discover)
......@@ -23,7 +28,13 @@ if(TARGET PkgConfig::Markdown)
endif()
#notifier
add_library(DiscoverPackageKitNotifier MODULE PackageKitNotifier.cpp)
set (DiscoverPackageKitNotifier_SRCS
PackageKitNotifier.cpp
)
ecm_qt_declare_logging_category(DiscoverPackageKitNotifier_SRCS HEADER libdiscover_backend_debug.h IDENTIFIER LIBDISCOVER_BACKEND_LOG CATEGORY_NAME org.kde.plasma.libdiscover.backend)
add_library(DiscoverPackageKitNotifier MODULE ${DiscoverPackageKitNotifier_SRCS})
target_link_libraries(DiscoverPackageKitNotifier PRIVATE PK::packagekitqt5 Discover::Notifiers KF5::I18n KF5::Notifications KF5::ConfigCore)
set_target_properties(DiscoverPackageKitNotifier PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/plasma-discover)
......
......@@ -26,6 +26,7 @@
#include <PackageKit/Details>
#include <utils.h>
#include "config-paths.h"
#include "libdiscover_backend_debug.h"
LocalFilePKResource::LocalFilePKResource(QUrl path, PackageKitBackend* parent)
: PackageKitResource(path.toString(), path.toString(), parent)
......@@ -80,7 +81,7 @@ void LocalFilePKResource::fetchDetails()
else
qWarning() << "could not find an executable desktop file for" << m_path << "among" << files;
});
connect(transaction2, &PackageKit::Transaction::finished, this, [] {qDebug() << "."; });
connect(transaction2, &PackageKit::Transaction::finished, this, [] {qCDebug(LIBDISCOVER_BACKEND_LOG) << "."; });
}
void LocalFilePKResource::invokeApplication() const
......
......@@ -24,6 +24,7 @@
#include "PackageKitMessages.h"
#include "utils.h"
#include "LocalFilePKResource.h"
#include "libdiscover_backend_debug.h"
#include <resources/AbstractResource.h>
#include <QDebug>
#include <QTimer>
......@@ -83,7 +84,7 @@ void PKTransaction::trigger(PackageKit::Transaction::TransactionFlags flags)
//FIXME this state shouldn't exist
qWarning() << "Installing no packages found!";
for(auto app : m_apps) {
qDebug() << "app" << app << app->state() << static_cast<PackageKitResource*>(app)->packages();
qCDebug(LIBDISCOVER_BACKEND_LOG) << "app" << app << app->state() << static_cast<PackageKitResource*>(app)->packages();
}
setStatus(Transaction::DoneWithErrorStatus);
......@@ -98,7 +99,7 @@ void PKTransaction::trigger(PackageKit::Transaction::TransactionFlags flags)
};
Q_ASSERT(m_trans);
// connect(m_trans.data(), &PackageKit::Transaction::statusChanged, this, [this]() { qDebug() << "state..." << m_trans->status(); });
// connect(m_trans.data(), &PackageKit::Transaction::statusChanged, this, [this]() { qCDebug(LIBDISCOVER_BACKEND_LOG) << "state..." << m_trans->status(); });
connect(m_trans.data(), &PackageKit::Transaction::package, this, &PKTransaction::packageResolved);
connect(m_trans.data(), &PackageKit::Transaction::finished, this, &PKTransaction::cleanup);
connect(m_trans.data(), &PackageKit::Transaction::errorCode, this, &PKTransaction::errorFound);
......
......@@ -54,6 +54,7 @@
#include "utils.h"
#include "config-paths.h"
#include "libdiscover_backend_debug.h"
DISCOVER_BACKEND_PLUGIN(PackageKitBackend)
......@@ -208,7 +209,7 @@ void PackageKitBackend::reloadPackageList()
}
}
qDebug() << "no packages for" << component.id();
qCDebug(LIBDISCOVER_BACKEND_LOG) << "no packages for" << component.id();
continue;
}
neededPackages += pkgNames;
......@@ -221,7 +222,7 @@ void PackageKitBackend::reloadPackageList()
neededPackages.removeDuplicates();
resolvePackages(neededPackages);
} else {
qDebug() << "empty appstream db";
qCDebug(LIBDISCOVER_BACKEND_LOG) << "empty appstream db";
if (PackageKit::Daemon::backendName() == QLatin1String("aptcc") || PackageKit::Daemon::backendName().isEmpty()) {
checkForUpdates();
}
......@@ -395,7 +396,7 @@ T PackageKitBackend::resourcesByPackageNames(const QStringList &pkgnames) const
void PackageKitBackend::checkForUpdates()
{
if (PackageKit::Daemon::global()->offline()->updateTriggered()) {
qDebug() << "Won't be checking for updates again, the system needs a reboot to apply the fetched offline updates.";
qCDebug(LIBDISCOVER_BACKEND_LOG) << "Won't be checking for updates again, the system needs a reboot to apply the fetched offline updates.";
return;
}
......@@ -497,7 +498,7 @@ ResultsStream * PackageKitBackend::findResourceByPackageName(const QUrl& url)
}
}
// if (!pkg)
// qDebug() << "could not find" << host << deprecatedHost;
// qCDebug(LIBDISCOVER_BACKEND_LOG) << "could not find" << host << deprecatedHost;
}
}
return new ResultsStream(QStringLiteral("PackageKitStream-url"), pkg ? QVector<AbstractResource*>{pkg} : QVector<AbstractResource*>{});
......
......@@ -38,6 +38,7 @@
#include <KConfigGroup>
#include "pk-offline-private.h"
#include "libdiscover_backend_debug.h"
PackageKitNotifier::PackageKitNotifier(QObject* parent)
: BackendNotifierModule(parent)
......@@ -104,7 +105,7 @@ void PackageKitNotifier::checkOfflineUpdates()
if (!QFile::exists(QStringLiteral(PK_OFFLINE_RESULTS_FILENAME))) {
return;
}
qDebug() << "found offline update results at " << PK_OFFLINE_RESULTS_FILENAME;
qCDebug(LIBDISCOVER_BACKEND_LOG) << "found offline update results at " << PK_OFFLINE_RESULTS_FILENAME;
KDesktopFile file(QStringLiteral(PK_OFFLINE_RESULTS_FILENAME));
KConfigGroup group(&file, PK_OFFLINE_RESULTS_GROUP);
......@@ -173,7 +174,7 @@ void PackageKitNotifier::recheckSystemUpdate()
void PackageKitNotifier::setupGetUpdatesTransaction(PackageKit::Transaction* trans)
{
qDebug() << "using..." << trans << trans->tid().path();
qCDebug(LIBDISCOVER_BACKEND_LOG) << "using..." << trans << trans->tid().path();
trans->setProperty("normalUpdates", 0);
trans->setProperty("securityUpdates", 0);
......@@ -314,5 +315,5 @@ void PackageKitNotifier::onRequireRestart(PackageKit::Transaction::Restart type,
{
PackageKit::Transaction* t = qobject_cast<PackageKit::Transaction*>(sender());
t->setProperty("requireRestart", qMax<int>(t->property("requireRestart").toInt(), type));
qDebug() << "RESTART" << type << "is required for package" << packageID;
qCDebug(LIBDISCOVER_BACKEND_LOG) << "RESTART" << type << "is required for package" << packageID;
}
......@@ -30,6 +30,8 @@
#include <KConfigGroup>
#include <KLocalizedString>
#include "libdiscover_backend_debug.h"
int percentageWithStatus(PackageKit::Transaction::Status status, uint percentage)
{
const auto was = percentage;
......@@ -43,12 +45,12 @@ int percentageWithStatus(PackageKit::Transaction::Status status, uint percentage
};
const auto idx = statuses.value(status, -1);
if (idx < 0) {
qDebug() << "Status not present" << status << "among" << statuses .keys() << percentage;
qCDebug(LIBDISCOVER_BACKEND_LOG) << "Status not present" << status << "among" << statuses .keys() << percentage;
return -1;
}
percentage = (idx * 100 + percentage) / 2 /*the maximum in statuses*/;
}
qDebug() << "reporting progress with status:" << status << percentage << was;
qCDebug(LIBDISCOVER_BACKEND_LOG) << "reporting progress with status:" << status << percentage << was;
return percentage;
}
......@@ -198,7 +200,7 @@ void PackageKitUpdater::start()
void PackageKitUpdater::finished(PackageKit::Transaction::Exit exit, uint /*time*/)
{
// qDebug() << "update finished!" << exit << time;
// qCDebug(LIBDISCOVER_BACKEND_LOG) << "update finished!" << exit << time;
if (!m_proceedFunctions.isEmpty())
return;
const bool cancel = exit == PackageKit::Transaction::ExitCancelled;
......@@ -373,7 +375,7 @@ AbstractBackendUpdater::State toUpdateState(PackageKit::Transaction::Status t)
case PackageKit::Transaction::StatusCancel:
return AbstractBackendUpdater::Done;
default:
qDebug() << "unknown packagekit status" << t;
qCDebug(LIBDISCOVER_BACKEND_LOG) << "unknown packagekit status" << t;
return AbstractBackendUpdater::None;
}
Q_UNREACHABLE();
......
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