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

Use logging categories

parent 8fac53a4
......@@ -30,3 +30,4 @@ org.kde.pim.imapresource.trace resource imap trace (kdepim-runtime) IDENTIFIER [
org.kde.pim.kolabresource.trace resource kolab trace (kdepim-runtime) IDENTIFIER [KOLABRESOURCE_TRACE]
org.kde.pim.google.calendar resource google calendar (kdepim-runtime) IDENTIFIER [GOOGLE_CALENDAR_LOG]
org.kde.pim.vcarddirresource vcarddir resource (kdepim-runtime) IDENTIFIER [VCARDDIRRESOURCE_LOG]
org.kde.pim.migration migration (kdepim-runtime) IDENTIFIER [MIGRATION_LOG]
......@@ -22,7 +22,7 @@
#include <AkonadiCore/CollectionCreateJob>
#include <AkonadiCore/ItemCreateJob>
#include <QDebug>
#include "migration_debug.h"
using namespace Akonadi;
......@@ -81,7 +81,7 @@ void EntityTreeCreateJob::collectionCreateJobDone(KJob *job)
Collection createdCollection = collectionCreateJob->collection();
if (job->error()) {
qDebug() << job->errorString();
qCDebug(MIGRATION_LOG) << job->errorString();
return;
}
......@@ -90,7 +90,7 @@ void EntityTreeCreateJob::collectionCreateJobDone(KJob *job)
Item::List::iterator it;
const Item::List::iterator end = m_items.end();
for (it = m_items.begin(); it != end; ++it) {
qDebug() << "updating items";
qCDebug(MIGRATION_LOG) << "updating items";
if (it->parentCollection().id() == creationId) {
it->setParentCollection(createdCollection);
}
......
......@@ -4,6 +4,8 @@ set(gid_SRCS
${MIGRATION_AKONADI_SHARED_SOURCES}
)
ecm_qt_declare_logging_category(gid_SRCS HEADER migration_debug.h IDENTIFIER MIGRATION_LOG CATEGORY_NAME org.kde.pim.migration)
add_library(gidmigration STATIC ${gid_SRCS})
target_link_libraries(gidmigration
KF5::AkonadiCore
......
......@@ -24,7 +24,7 @@
#include <KConfigGroup>
#include <KLocalizedString>
#include <QDebug>
#include "migration_debug.h"
#include <QIcon>
#include <QApplication>
#include <infodialog.h>
......@@ -71,7 +71,7 @@ int main(int argc, char **argv)
const QString mimeType = parser.value(QStringLiteral("mimetype"));
if (mimeType.isEmpty()) {
qWarning() << "set the mimetype to migrate";
qCWarning(MIGRATION_LOG) << "set the mimetype to migrate";
return 5;
}
......
......@@ -19,7 +19,7 @@
#include "infodialog.h"
#include <QDebug>
#include "migration_debug.h"
#include <QIcon>
#include <QApplication>
......@@ -107,19 +107,19 @@ void InfoDialog::message(KMigratorBase::MessageType type, const QString &msg)
case KMigratorBase::Success:
item->setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok-apply")));
mChange = true;
qDebug() << msg;
qCDebug(MIGRATION_LOG) << msg;
break;
case KMigratorBase::Skip:
item->setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok")));
qDebug() << msg;
qCDebug(MIGRATION_LOG) << msg;
break;
case KMigratorBase::Info:
item->setIcon(QIcon::fromTheme(QStringLiteral("dialog-information")));
qDebug() << msg;
qCDebug(MIGRATION_LOG) << msg;
break;
case KMigratorBase::Warning:
item->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning")));
qDebug() << msg;
qCDebug(MIGRATION_LOG) << msg;
break;
case KMigratorBase::Error:
{
......@@ -128,11 +128,11 @@ void InfoDialog::message(KMigratorBase::MessageType type, const QString &msg)
currentFont.setBold(true);
item->setFont(currentFont);
mError = true;
qCritical() << msg;
qCCritical(MIGRATION_LOG) << msg;
break;
}
default:
qCritical() << "WTF?";
qCCritical(MIGRATION_LOG) << "WTF?";
}
mAutoScrollList = autoScroll;
......
......@@ -26,7 +26,7 @@
#include <KSharedConfig>
#include <KConfigGroup>
#include <KLocalizedString>
#include <QDebug>
#include "migration_debug.h"
#include <QCoreApplication>
#include <QFile>
#include <QMetaEnum>
......@@ -67,7 +67,7 @@ KMigratorBase::KMigratorBase() : m_logFile(nullptr)
if (!m_logFile->open(QFile::Append)) {
delete m_logFile;
m_logFile = nullptr;
qWarning() << "Unable to open log file: " << logFileName;
qCWarning(MIGRATION_LOG) << "Unable to open log file: " << logFileName;
}
logMessage(Info, QStringLiteral("Starting migration..."));
connect(this, &KMigratorBase::message, this, &KMigratorBase::logMessage);
......
......@@ -20,7 +20,7 @@
*/
#include "migratorbase.h"
#include <QDebug>
#include "migration_debug.h"
#include <KLocalizedString>
#include <AkonadiCore/servermanager.h>
#include <QFile>
......@@ -110,7 +110,7 @@ void MigratorBase::setLogfile(const QString &logfile)
mLogFile.reset(new QFile(logfile));
if (!mLogFile->open(QFile::Append)) {
mLogFile.reset();
qWarning() << "Unable to open log file: " << logfile;
qCWarning(MIGRATION_LOG) << "Unable to open log file: " << logfile;
}
} else {
mLogFile.reset();
......@@ -152,7 +152,7 @@ bool MigratorBase::canStart()
void MigratorBase::start()
{
if (mMigrationState == InProgress) {
qWarning() << "already running";
qCWarning(MIGRATION_LOG) << "already running";
return;
}
if (!canStart()) {
......@@ -170,17 +170,17 @@ void MigratorBase::start()
void MigratorBase::pause()
{
qWarning() << "pause is not implemented";
qCWarning(MIGRATION_LOG) << "pause is not implemented";
}
void MigratorBase::resume()
{
qWarning() << "resume is not implemented";
qCWarning(MIGRATION_LOG) << "resume is not implemented";
}
void MigratorBase::abort()
{
qWarning() << "abort is not implemented";
qCWarning(MIGRATION_LOG) << "abort is not implemented";
}
void MigratorBase::logMessage(MigratorBase::MessageType type, const QString &msg)
......@@ -221,7 +221,7 @@ void MigratorBase::setMigrationState(MigratorBase::MigrationState state)
Q_EMIT stateChanged(mMigrationState);
return;
default:
qWarning() << "invalid state " << state;
qCWarning(MIGRATION_LOG) << "invalid state " << state;
Q_ASSERT(false);
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