Commit 54bb90cb authored by Andre Heinecke's avatar Andre Heinecke

Add libkleo logging category and QDebug -> QCDebug

parent 1c001cd3
...@@ -78,6 +78,7 @@ set(libkleo_core_SRCS ...@@ -78,6 +78,7 @@ set(libkleo_core_SRCS
kleo/kconfigbasedkeyfilter.cpp kleo/kconfigbasedkeyfilter.cpp
kleo/keyfiltermanager.cpp kleo/keyfiltermanager.cpp
) )
ecm_qt_declare_logging_category(libkleo_core_SRCS HEADER libkleo_debug.h IDENTIFIER LIBKLEO_LOG CATEGORY_NAME log_libkleo)
set(libkleo_ui_common_SRCS set(libkleo_ui_common_SRCS
ui/dnattributeorderconfigwidget.cpp ui/dnattributeorderconfigwidget.cpp
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include "exception.h" #include "exception.h"
#include "cryptobackendfactory.h" #include "cryptobackendfactory.h"
#include "libkleo_debug.h"
#include <KConfigGroup> #include <KConfigGroup>
#include <KLocalizedString> #include <KLocalizedString>
#include <KConfig> #include <KConfig>
...@@ -71,7 +73,7 @@ QString ChecksumDefinition::installPath() ...@@ -71,7 +73,7 @@ QString ChecksumDefinition::installPath()
if (QCoreApplication::instance()) { if (QCoreApplication::instance()) {
*ip = QCoreApplication::applicationDirPath(); *ip = QCoreApplication::applicationDirPath();
} else { } else {
qWarning() << "checksumdefinition.cpp: installPath() called before QCoreApplication was constructed"; qCWarning(LIBKLEO_LOG) << "checksumdefinition.cpp: installPath() called before QCoreApplication was constructed";
} }
} }
return *ip; return *ip;
...@@ -170,7 +172,7 @@ static void parse_command(QString cmdline, const QString &id, const QString &whi ...@@ -170,7 +172,7 @@ static void parse_command(QString cmdline, const QString &id, const QString &whi
if (errors == KShell::FoundMeta) { if (errors == KShell::FoundMeta) {
throw ChecksumDefinitionError(id, i18n("'%1' too complex (would need shell)", whichCommand)); throw ChecksumDefinitionError(id, i18n("'%1' too complex (would need shell)", whichCommand));
} }
qDebug() << "ChecksumDefinition[" << id << ']' << l; qCDebug(LIBKLEO_LOG) << "ChecksumDefinition[" << id << ']' << l;
if (l.empty()) { if (l.empty()) {
throw ChecksumDefinitionError(id, i18n("'%1' entry is empty/missing", whichCommand)); throw ChecksumDefinitionError(id, i18n("'%1' entry is empty/missing", whichCommand));
} }
...@@ -193,13 +195,13 @@ static void parse_command(QString cmdline, const QString &id, const QString &whi ...@@ -193,13 +195,13 @@ static void parse_command(QString cmdline, const QString &id, const QString &whi
} }
switch (*method) { switch (*method) {
case ChecksumDefinition::CommandLine: case ChecksumDefinition::CommandLine:
qDebug() << "ChecksumDefinition[" << id << ']' << *command << *prefix << FILE_PLACEHOLDER << *suffix; qCDebug(LIBKLEO_LOG) << "ChecksumDefinition[" << id << ']' << *command << *prefix << FILE_PLACEHOLDER << *suffix;
break; break;
case ChecksumDefinition::NewlineSeparatedInputFile: case ChecksumDefinition::NewlineSeparatedInputFile:
qDebug() << "ChecksumDefinition[" << id << ']' << "find | " << *command << *prefix; qCDebug(LIBKLEO_LOG) << "ChecksumDefinition[" << id << ']' << "find | " << *command << *prefix;
break; break;
case ChecksumDefinition::NullSeparatedInputFile: case ChecksumDefinition::NullSeparatedInputFile:
qDebug() << "ChecksumDefinition[" << id << ']' << "find -print0 | " << *command << *prefix; qCDebug(LIBKLEO_LOG) << "ChecksumDefinition[" << id << ']' << "find -print0 | " << *command << *prefix;
break; break;
case ChecksumDefinition::NumArgumentPassingMethods: case ChecksumDefinition::NumArgumentPassingMethods:
assert(!"Should not happen"); assert(!"Should not happen");
...@@ -317,7 +319,7 @@ static bool start_command(QProcess *p, const char *functionName, ...@@ -317,7 +319,7 @@ static bool start_command(QProcess *p, const char *functionName,
const QStringList &files, ChecksumDefinition::ArgumentPassingMethod method) const QStringList &files, ChecksumDefinition::ArgumentPassingMethod method)
{ {
if (!p) { if (!p) {
qWarning() << functionName << ": process == NULL"; qCWarning(LIBKLEO_LOG) << functionName << ": process == NULL";
return false; return false;
} }
...@@ -327,13 +329,13 @@ static bool start_command(QProcess *p, const char *functionName, ...@@ -327,13 +329,13 @@ static bool start_command(QProcess *p, const char *functionName,
assert(!"Should not happen"); assert(!"Should not happen");
case ChecksumDefinition::CommandLine: case ChecksumDefinition::CommandLine:
qDebug("[%p] Starting %s %s", qCDebug(LIBKLEO_LOG) << "Starting: " << cmd << " " << args.join(QStringLiteral(" "));
(void *)p, qPrintable(cmd), qPrintable(args.join(QStringLiteral(" "))));
p->start(cmd, args, QIODevice::ReadOnly); p->start(cmd, args, QIODevice::ReadOnly);
return true; return true;
case ChecksumDefinition::NewlineSeparatedInputFile: case ChecksumDefinition::NewlineSeparatedInputFile:
case ChecksumDefinition::NullSeparatedInputFile: case ChecksumDefinition::NullSeparatedInputFile:
qCDebug(LIBKLEO_LOG) << "Starting: " << cmd << " " << args.join(QStringLiteral(" "));
p->start(cmd, args, QIODevice::ReadWrite); p->start(cmd, args, QIODevice::ReadWrite);
if (!p->waitForStarted()) { if (!p->waitForStarted()) {
return false; return false;
...@@ -390,7 +392,7 @@ std::vector< shared_ptr<ChecksumDefinition> > ChecksumDefinition::getChecksumDef ...@@ -390,7 +392,7 @@ std::vector< shared_ptr<ChecksumDefinition> > ChecksumDefinition::getChecksumDef
const shared_ptr<ChecksumDefinition> ad(new KConfigBasedChecksumDefinition(KConfigGroup(config, group))); const shared_ptr<ChecksumDefinition> ad(new KConfigBasedChecksumDefinition(KConfigGroup(config, group)));
result.push_back(ad); result.push_back(ad);
} catch (const std::exception &e) { } catch (const std::exception &e) {
qDebug() << e.what(); qCDebug(LIBKLEO_LOG) << e.what();
errors.push_back(QString::fromLocal8Bit(e.what())); errors.push_back(QString::fromLocal8Bit(e.what()));
} catch (...) { } catch (...) {
errors.push_back(i18n("Caught unknown exception in group %1", group)); errors.push_back(i18n("Caught unknown exception in group %1", group));
......
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
#include "specialjob.h" #include "specialjob.h"
#include "keyformailboxjob.h" #include "keyformailboxjob.h"
#include "libkleo_debug.h"
#include <gpgme++/error.h> #include <gpgme++/error.h>
#include <QCoreApplication> #include <QCoreApplication>
...@@ -78,18 +80,18 @@ Kleo::Job::~Job() ...@@ -78,18 +80,18 @@ Kleo::Job::~Job()
void Kleo::Job::showErrorDialog(QWidget *, const QString &) const void Kleo::Job::showErrorDialog(QWidget *, const QString &) const
{ {
qDebug() << "Kleo::Job::showErrorDialog() should be reimplemented in Kleo::Job subclasses!"; qCDebug(LIBKLEO_LOG) << "Kleo::Job::showErrorDialog() should be reimplemented in Kleo::Job subclasses!";
} }
QString Kleo::Job::auditLogAsHtml() const QString Kleo::Job::auditLogAsHtml() const
{ {
qDebug() << "Kleo::Job::auditLogAsHtml() should be reimplemented in Kleo::Job subclasses!"; qCDebug(LIBKLEO_LOG) << "Kleo::Job::auditLogAsHtml() should be reimplemented in Kleo::Job subclasses!";
return QString(); return QString();
} }
GpgME::Error Kleo::Job::auditLogError() const GpgME::Error Kleo::Job::auditLogError() const
{ {
qDebug() << "Kleo::Job::auditLogError() should be reimplemented in Kleo::Job subclasses!"; qCDebug(LIBKLEO_LOG) << "Kleo::Job::auditLogError() should be reimplemented in Kleo::Job subclasses!";
return GpgME::Error::fromCode(GPG_ERR_NOT_IMPLEMENTED); return GpgME::Error::fromCode(GPG_ERR_NOT_IMPLEMENTED);
} }
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include "cryptobackendfactory.h" #include "cryptobackendfactory.h"
#include "stl_util.h" #include "stl_util.h"
#include "libkleo_debug.h"
#include <kconfig.h> #include <kconfig.h>
#include <kconfiggroup.h> #include <kconfiggroup.h>
#include <KLocalizedString> #include <KLocalizedString>
...@@ -240,7 +242,7 @@ void KeyFilterManager::reload() ...@@ -240,7 +242,7 @@ void KeyFilterManager::reload()
} }
} }
std::stable_sort(d->filters.begin(), d->filters.end(), ByDecreasingSpecificity()); std::stable_sort(d->filters.begin(), d->filters.end(), ByDecreasingSpecificity());
qDebug() << "final filter count is" << d->filters.size(); qCDebug(LIBKLEO_LOG) << "final filter count is" << d->filters.size();
} }
QAbstractItemModel *KeyFilterManager::model() const QAbstractItemModel *KeyFilterManager::model() const
......
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