Commit 8eb1ead7 authored by Volker Krause's avatar Volker Krause
Browse files

Use categorized logging

parent 4133625d
......@@ -179,6 +179,6 @@ install(FILES
)
install(EXPORT UserFeedbackTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE UserFeedbackTarget.cmake)
install(FILES org_kde_UserFeedback.categories DESTINATION etc/xdg)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
org.kde.UserFeedback User Feedback Framework
......@@ -24,4 +24,7 @@
#define QStringLiteral(str) QString::fromUtf8("" str "", sizeof(str) - 1)
#define qCDebug(cat) qDebug()
#define qCWarning(cat) qWarning()
#endif
/*
Copyright (C) 2017 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef USERFEEDBACK_CORE_LOGGING_H
#define USERFEEDBACK_CORE_LOGGING_H
#include <qglobal.h>
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
#include <QLoggingCategory>
namespace UserFeedback {
Q_DECLARE_LOGGING_CATEGORY(Log)
}
#endif
#endif
......@@ -17,6 +17,7 @@
#include "propertyratiosource.h"
#include "abstractdatasource_p.h"
#include "logging_p.h"
#include <QDebug>
#include <QHash>
......@@ -111,13 +112,13 @@ PropertyRatioSource::PropertyRatioSource(QObject *obj, const char *propertyName,
auto idx = obj->metaObject()->indexOfProperty(propertyName);
Q_ASSERT(idx >= 0);
if (idx < 0) {
qWarning() << "Property" << propertyName << "not found in" << obj << "!";
qCWarning(Log) << "Property" << propertyName << "not found in" << obj << "!";
return;
}
d->property = obj->metaObject()->property(idx);
if (!d->property.hasNotifySignal()) {
qWarning() << "Property" << propertyName << "has no notification signal!";
qCWarning(Log) << "Property" << propertyName << "has no notification signal!";
return;
}
......
......@@ -17,6 +17,7 @@
#include <config-userfeedback-version.h>
#include "logging_p.h"
#include "provider.h"
#include "provider_p.h"
#include "abstractdatasource.h"
......@@ -41,6 +42,14 @@
#include <algorithm>
#include <numeric>
namespace UserFeedback {
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
Q_LOGGING_CATEGORY(Log, "org.kde.UserFeedback", QtInfoMsg)
#elif QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
Q_LOGGING_CATEGORY(Log, "org.kde.UserFeedback")
#endif
}
using namespace UserFeedback;
ProviderPrivate::ProviderPrivate(Provider *qq)
......@@ -134,7 +143,7 @@ void ProviderPrivate::store()
void ProviderPrivate::aboutToQuit()
{
qDebug() << Q_FUNC_INFO;
qCDebug(Log) << Q_FUNC_INFO;
store();
}
......@@ -233,7 +242,7 @@ void ProviderPrivate::submitFinished()
Q_ASSERT(reply);
if (reply->error() != QNetworkReply::NoError) {
qWarning() << "failed to submit user feedback:" << reply->errorString() << reply->readAll();
qCWarning(Log) << "failed to submit user feedback:" << reply->errorString() << reply->readAll();
return;
}
......@@ -257,7 +266,7 @@ void ProviderPrivate::submitFinished()
bool ProviderPrivate::selectSurvey(const SurveyInfo &survey) const
{
qDebug() << Q_FUNC_INFO << "got survey:" << survey.url();
qCDebug(Log) << "got survey:" << survey.url();
if (!survey.isValid() || completedSurveys.contains(QString::number(survey.id())))
return false;
......@@ -320,7 +329,7 @@ Provider::Provider(QObject *parent) :
QObject(parent),
d(new ProviderPrivate(this))
{
qDebug() << Q_FUNC_INFO;
qCDebug(Log);
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
......@@ -452,7 +461,7 @@ void Provider::setSurveyCompleted(const SurveyInfo &info)
void Provider::submit()
{
if (!d->serverUrl.isValid()) {
qWarning() << "No feedback server URL specified!";
qCWarning(Log) << "No feedback server URL specified!";
return;
}
......
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