Port to categorized logging

This commit is contained in:
Luca Beltrame 2015-03-20 00:15:04 +01:00
parent 4021ccaf23
commit 0084798a2c
13 changed files with 125 additions and 23 deletions

View file

@ -15,6 +15,7 @@ set(danbooru_client_SRCS
blacklistpage.cpp
mainwindow.cpp
danbooru_client.cpp
danbooru_client_debug.cpp
)
add_subdirectory(libdanbooru)

View file

@ -18,7 +18,7 @@
*/
#include <QApplication>
#include <QDebug>
#include "danbooru_client_debug.h"
#include <QUrl>
#include <QCommandLineParser>

View file

@ -0,0 +1,23 @@
/*
* Copyright 2015 Luca Beltrame <lbeltrame@kde.org>
*
* This file is part of Danbooru Client.
*
* Danbooru Client is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Danbooru Client 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
*/
#include "danbooru_client_debug.h"
Q_LOGGING_CATEGORY(DANBOORU_CLIENT, "org.dennogumi.danbooru_client")

View file

@ -0,0 +1,27 @@
/*
* Copyright 2015 Luca Beltrame <lbeltrame@kde.org>
*
* This file is part of Danbooru Client.
*
* Danbooru Client is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Danbooru Client 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DANBOORU_CLIENT_DEBUG_H
#define DANBOORU_CLIENT_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(DANBOORU_CLIENT)
#endif

View file

@ -24,7 +24,7 @@
#include "libdanbooru/danbooruservice.h"
#include <QCryptographicHash>
#include <QDebug>
#include "danbooru_client_debug.h"
#include <KWallet>

View file

@ -15,7 +15,8 @@ set (libdanbooru_SRCS
danbooruservice.cpp
danboorupost.cpp
danboorutag.cpp
utils.cpp)
utils.cpp
libdanbooru_debug.cpp)
ecm_setup_version(${libdanbooru_VERSION} VARIABLE_PREFIX LIBDANBOORU VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/libdanbooru_version.h)

View file

@ -24,7 +24,7 @@
// Qt
#include <QDebug>
#include "libdanbooru_debug.h"
// KDE
@ -88,7 +88,7 @@ void DanbooruService::getPostList()
QUrl danbooruUrl = requestUrl(m_url, POST_URL, m_username,
m_password, parameters, m_tags);
// qDebug() << "Final constructed post URL" << danbooruUrl;
// qCDebug(LIBDANBOORU) << "Final constructed post URL" << danbooruUrl;
KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
KIO::HideProgressInfo);
@ -113,7 +113,7 @@ void DanbooruService::getTagList(int limit, QString name)
QUrl danbooruUrl = requestUrl(m_url, TAG_URL, m_username, m_password,
parameters);
// qDebug() << "Final constructed tag URL" << danbooruUrl.url();
// qCDebug(LIBDANBOORU) << "Final constructed tag URL" << danbooruUrl.url();
KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
KIO::HideProgressInfo);
@ -135,7 +135,7 @@ void DanbooruService::getPool(int poolId, int page)
QUrl danbooruUrl = requestUrl(m_url, POOL_DATA_URL, m_username,
m_password, parameters);
// qDebug() << "Final constructed pool URL" << danbooruUrl.url();
// qCDebug(LIBDANBOORU) << "Final constructed pool URL" << danbooruUrl.url();
KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
KIO::HideProgressInfo);
@ -164,7 +164,7 @@ void DanbooruService::getPoolList()
m_password, map);
}
// qDebug() << "Final constructed pool list URL" << danbooruUrl.url();
// qCDebug(LIBDANBOORU) << "Final constructed pool list URL" << danbooruUrl.url();
KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
KIO::HideProgressInfo);
@ -198,7 +198,7 @@ void DanbooruService::getPoolList()
Q_EMIT(poolDownloaded(pool));
}
//qDebug() << "Pool download finished!";
//qCDebug(LIBDANBOORU) << "Pool download finished!";
Q_EMIT(poolDownloadFinished());
}
@ -235,7 +235,7 @@ void DanbooruService::getRelatedTags(const QStringList &tags,
QUrl danbooruUrl = requestUrl(m_url, RELATED_TAG_URL, m_username,
m_password, parameters, tags);
// qDebug() << "Final constructed related tag URL" << danbooruUrl;
// qCDebug(LIBDANBOORU) << "Final constructed related tag URL" << danbooruUrl;
StoredTransferJob *job = KIO::storedGet(
@ -398,7 +398,7 @@ void DanbooruService::processTagList(KJob *job) {
void DanbooruService::processPostList(KJob *job)
{
// qDebug() << "Got post data OK";
// qCDebug(LIBDANBOORU) << "Got post data OK";
if (job->error()) {
Q_EMIT(downloadError(job->errorString()));
@ -451,7 +451,7 @@ void DanbooruService::processPostList(KJob *job)
QPixmap pix;
// qDebug() << "About to donwload images";
// qCDebug(LIBDANBOORU) << "About to donwload images";
if (m_cache && m_cache->findPixmap(post->thumbnailUrl().url(), &pix)) {
@ -460,7 +460,7 @@ void DanbooruService::processPostList(KJob *job)
m_postsToFetch--;
if (m_postsToFetch == 0) {
qDebug() << "Post download finished";
qCDebug(LIBDANBOORU) << "Post download finished";
Q_EMIT(postDownloadFinished());
}
@ -500,18 +500,18 @@ void DanbooruService::processPostList(KJob *job)
if (m_cache)
{
//qDebug() << "Inserting item in cache";
//qCDebug(LIBDANBOORU) << "Inserting item in cache";
m_cache->insertPixmap(post->thumbnailUrl().url(), pix);
}
m_postsToFetch--; // One less post to do
//qDebug() << "Current posts remaining" << m_currentPosts;
//qCDebug(LIBDANBOORU) << "Current posts remaining" << m_currentPosts;
Q_EMIT(postDownloaded(post));
if (m_postsToFetch == 0)
{
qDebug() << "Post download finished";
qCDebug(LIBDANBOORU) << "Post download finished";
Q_EMIT(postDownloadFinished());
}

View file

@ -0,0 +1,23 @@
/*
* Copyright 2015 Luca Beltrame <lbeltrame@kde.org>
*
* This file is part of Danbooru Client.
*
* Danbooru Client is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Danbooru Client 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libdanbooru_debug.h"
Q_LOGGING_CATEGORY(LIBDANBOORU, "org.dennogumi.libdanbooru")

View file

@ -0,0 +1,27 @@
/*
* Copyright 2015 Luca Beltrame <lbeltrame@kde.org>
*
* This file is part of Danbooru Client.
*
* Danbooru Client is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Danbooru Client 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DANBOORU_CLIENT_DEBUG_H
#define DANBOORU_CLIENT_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(LIBDANBOORU)
#endif

View file

@ -30,7 +30,7 @@
// KDE
#include <QDebug>
#include "libdanbooru_debug.h"
namespace Danbooru
{
@ -141,7 +141,7 @@ QList< QVariant > parseDanbooruResult(QByteArray data, QString xlmElement, bool*
QXmlStreamAttributes attributes = reader.attributes();
// qDebug() << attributes;
// qCDebug(LIBDANBOORU) << attributes;
for (auto attribute : attributes) {
values.insert(attribute.name().toString(),
@ -150,7 +150,7 @@ QList< QVariant > parseDanbooruResult(QByteArray data, QString xlmElement, bool*
if (values.isEmpty()) {
*result = false;
qWarning() << "No results found when parsing XML";
qCWarning(LIBDANBOORU) << "No results found when parsing XML";
return QList<QVariant>();
}

View file

@ -26,7 +26,7 @@
#include <QGuiApplication>
#include <QStandardPaths>
#include <QUrl>
#include <QDebug>
#include "danbooru_client_debug.h"
#include <QDockWidget>
#include <QQuickItem>
#include <QFileDialog>
@ -520,7 +520,7 @@ void DanbooruMainWindow::slotHandleDownload(const QUrl &url, const QVariant tags
}
#ifdef WITH_KFILEMETADATA
qDebug() << "Local file" << localFile.toLocalFile();
qCDebug(DANBOORU_CLIENT) << "Local file" << localFile.toLocalFile();
KFileMetaData::UserMetaData meta(localFile.toLocalFile());
meta.setTags(tagList);
#endif

View file

@ -20,7 +20,7 @@
#include "danboorupoolmodel.h"
#include "libdanbooru/danboorupool.h"
#include <QDebug>
#include "danbooru_client_debug.h"
#include <KLocalizedString>

View file

@ -20,7 +20,7 @@
#include "danboorutagmodel.h"
#include "libdanbooru/danboorutag.h"
#include <QDebug>
#include "danbooru_client_debug.h"
#include <KLocalizedString>