From 0084798a2c6e5401fedc96725e9803814c78508d Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Fri, 20 Mar 2015 00:15:04 +0100 Subject: [PATCH] Port to categorized logging --- src/CMakeLists.txt | 1 + src/danbooru_client.cpp | 2 +- src/danbooru_client_debug.cpp | 23 +++++++++++++++++++++++ src/danbooru_client_debug.h | 27 +++++++++++++++++++++++++++ src/danbooruconnectwidget.cpp | 2 +- src/libdanbooru/CMakeLists.txt | 3 ++- src/libdanbooru/danbooruservice.cpp | 26 +++++++++++++------------- src/libdanbooru/libdanbooru_debug.cpp | 23 +++++++++++++++++++++++ src/libdanbooru/libdanbooru_debug.h | 27 +++++++++++++++++++++++++++ src/libdanbooru/utils.cpp | 6 +++--- src/mainwindow.cpp | 4 ++-- src/model/danboorupoolmodel.cpp | 2 +- src/model/danboorutagmodel.cpp | 2 +- 13 files changed, 125 insertions(+), 23 deletions(-) create mode 100644 src/danbooru_client_debug.cpp create mode 100644 src/danbooru_client_debug.h create mode 100644 src/libdanbooru/libdanbooru_debug.cpp create mode 100644 src/libdanbooru/libdanbooru_debug.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 998c682..dcf2012 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,6 +15,7 @@ set(danbooru_client_SRCS blacklistpage.cpp mainwindow.cpp danbooru_client.cpp + danbooru_client_debug.cpp ) add_subdirectory(libdanbooru) diff --git a/src/danbooru_client.cpp b/src/danbooru_client.cpp index d487908..1bbc56d 100644 --- a/src/danbooru_client.cpp +++ b/src/danbooru_client.cpp @@ -18,7 +18,7 @@ */ #include -#include +#include "danbooru_client_debug.h" #include #include diff --git a/src/danbooru_client_debug.cpp b/src/danbooru_client_debug.cpp new file mode 100644 index 0000000..9e33a59 --- /dev/null +++ b/src/danbooru_client_debug.cpp @@ -0,0 +1,23 @@ +/* + * Copyright 2015 Luca Beltrame + * + * 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 . + */ + +#include "danbooru_client_debug.h" +Q_LOGGING_CATEGORY(DANBOORU_CLIENT, "org.dennogumi.danbooru_client") + + diff --git a/src/danbooru_client_debug.h b/src/danbooru_client_debug.h new file mode 100644 index 0000000..6db7565 --- /dev/null +++ b/src/danbooru_client_debug.h @@ -0,0 +1,27 @@ +/* + * Copyright 2015 Luca Beltrame + * + * 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 . + */ + +#ifndef DANBOORU_CLIENT_DEBUG_H +#define DANBOORU_CLIENT_DEBUG_H + +#include +Q_DECLARE_LOGGING_CATEGORY(DANBOORU_CLIENT) + +#endif + diff --git a/src/danbooruconnectwidget.cpp b/src/danbooruconnectwidget.cpp index 820ba12..ba7326f 100644 --- a/src/danbooruconnectwidget.cpp +++ b/src/danbooruconnectwidget.cpp @@ -24,7 +24,7 @@ #include "libdanbooru/danbooruservice.h" #include -#include +#include "danbooru_client_debug.h" #include diff --git a/src/libdanbooru/CMakeLists.txt b/src/libdanbooru/CMakeLists.txt index 2ac144e..b7daf4f 100644 --- a/src/libdanbooru/CMakeLists.txt +++ b/src/libdanbooru/CMakeLists.txt @@ -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) diff --git a/src/libdanbooru/danbooruservice.cpp b/src/libdanbooru/danbooruservice.cpp index f2ba59f..040b896 100644 --- a/src/libdanbooru/danbooruservice.cpp +++ b/src/libdanbooru/danbooruservice.cpp @@ -24,7 +24,7 @@ // Qt -#include +#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()); } diff --git a/src/libdanbooru/libdanbooru_debug.cpp b/src/libdanbooru/libdanbooru_debug.cpp new file mode 100644 index 0000000..9309775 --- /dev/null +++ b/src/libdanbooru/libdanbooru_debug.cpp @@ -0,0 +1,23 @@ +/* + * Copyright 2015 Luca Beltrame + * + * 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 . + */ + +#include "libdanbooru_debug.h" +Q_LOGGING_CATEGORY(LIBDANBOORU, "org.dennogumi.libdanbooru") + + diff --git a/src/libdanbooru/libdanbooru_debug.h b/src/libdanbooru/libdanbooru_debug.h new file mode 100644 index 0000000..86e6c7a --- /dev/null +++ b/src/libdanbooru/libdanbooru_debug.h @@ -0,0 +1,27 @@ +/* + * Copyright 2015 Luca Beltrame + * + * 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 . + */ + +#ifndef DANBOORU_CLIENT_DEBUG_H +#define DANBOORU_CLIENT_DEBUG_H + +#include +Q_DECLARE_LOGGING_CATEGORY(LIBDANBOORU) + +#endif + diff --git a/src/libdanbooru/utils.cpp b/src/libdanbooru/utils.cpp index 6ed6a05..0aa2e83 100644 --- a/src/libdanbooru/utils.cpp +++ b/src/libdanbooru/utils.cpp @@ -30,7 +30,7 @@ // KDE -#include +#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(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 30e3644..f7ad46d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include "danbooru_client_debug.h" #include #include #include @@ -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 diff --git a/src/model/danboorupoolmodel.cpp b/src/model/danboorupoolmodel.cpp index 6c811ba..236db8c 100644 --- a/src/model/danboorupoolmodel.cpp +++ b/src/model/danboorupoolmodel.cpp @@ -20,7 +20,7 @@ #include "danboorupoolmodel.h" #include "libdanbooru/danboorupool.h" -#include +#include "danbooru_client_debug.h" #include diff --git a/src/model/danboorutagmodel.cpp b/src/model/danboorutagmodel.cpp index 62618a3..06aee1b 100644 --- a/src/model/danboorutagmodel.cpp +++ b/src/model/danboorutagmodel.cpp @@ -20,7 +20,7 @@ #include "danboorutagmodel.h" #include "libdanbooru/danboorutag.h" -#include +#include "danbooru_client_debug.h" #include