Switch to QT Category logging (#2206)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
+4
-3
@@ -7,6 +7,7 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QStringList>
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -38,13 +39,13 @@ Args::Args(const QApplication &app)
|
||||
|
||||
if (!parser.parse(app.arguments()))
|
||||
{
|
||||
qDebug() << "Warning: Unhandled options:"
|
||||
<< parser.unknownOptionNames();
|
||||
qCWarning(chatterinoArgs)
|
||||
<< "Unhandled options:" << parser.unknownOptionNames();
|
||||
}
|
||||
|
||||
if (parser.isSet("help"))
|
||||
{
|
||||
qDebug().noquote() << parser.helpText();
|
||||
qCInfo(chatterinoArgs).noquote() << parser.helpText();
|
||||
::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "singletons/Paths.hpp"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -40,7 +41,8 @@ void DownloadManager::setFile(QString fileURL, const QString &channelName)
|
||||
|
||||
void DownloadManager::onDownloadProgress(qint64 bytesRead, qint64 bytesTotal)
|
||||
{
|
||||
qDebug() << "Download progress: " << bytesRead << "/" << bytesTotal;
|
||||
qCDebug(chatterinoCommon)
|
||||
<< "Download progress: " << bytesRead << "/" << bytesTotal;
|
||||
}
|
||||
|
||||
void DownloadManager::onFinished(QNetworkReply *reply)
|
||||
@@ -48,11 +50,11 @@ void DownloadManager::onFinished(QNetworkReply *reply)
|
||||
switch (reply->error())
|
||||
{
|
||||
case QNetworkReply::NoError: {
|
||||
qDebug("file is downloaded successfully.");
|
||||
qCDebug(chatterinoCommon) << "file is downloaded successfully.";
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
qDebug() << reply->errorString().toLatin1();
|
||||
qCDebug(chatterinoCommon) << reply->errorString().toLatin1();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <QCryptographicHash>
|
||||
#include <QFile>
|
||||
#include <QtConcurrent>
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -123,7 +124,7 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
|
||||
|
||||
if (reply == nullptr)
|
||||
{
|
||||
qDebug() << "Unhandled request type";
|
||||
qCDebug(chatterinoCommon) << "Unhandled request type";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,7 +132,7 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
|
||||
{
|
||||
QObject::connect(
|
||||
data->timer_, &QTimer::timeout, worker, [reply, data]() {
|
||||
qDebug() << "Aborted!";
|
||||
qCDebug(chatterinoCommon) << "Aborted!";
|
||||
reply->abort();
|
||||
if (data->onError_)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QtConcurrent>
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
@@ -167,7 +168,7 @@ void NetworkRequest::execute()
|
||||
if (this->data->cache_ &&
|
||||
this->data->requestType_ != NetworkRequestType::Get)
|
||||
{
|
||||
qDebug() << "Can only cache GET requests!";
|
||||
qCDebug(chatterinoCommon) << "Can only cache GET requests!";
|
||||
this->data->cache_ = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/error/en.h>
|
||||
#include <QJsonDocument>
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -43,9 +44,9 @@ rapidjson::Document NetworkResult::parseRapidJson() const
|
||||
|
||||
if (result.Code() != rapidjson::kParseErrorNone)
|
||||
{
|
||||
qDebug() << "JSON parse error:"
|
||||
<< rapidjson::GetParseError_En(result.Code()) << "("
|
||||
<< result.Offset() << ")";
|
||||
qCWarning(chatterinoCommon)
|
||||
<< "JSON parse error:" << rapidjson::GetParseError_En(result.Code())
|
||||
<< "(" << result.Offset() << ")";
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
#ifdef DEBUG_OFF
|
||||
static constexpr QtMsgType logThreshold = QtWarningMsg;
|
||||
#else
|
||||
static constexpr QtMsgType logThreshold = QtDebugMsg;
|
||||
#endif
|
||||
|
||||
Q_LOGGING_CATEGORY(chatterinoApp, "chatterino.app", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoArgs, "chatterino.args", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoBenchmark, "chatterino.benchmark", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoBttv, "chatterino.bttv", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoCommon, "chatterino.cache", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoCache, "chatterino.common", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoEmoji, "chatterino.emoji", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoFfzemotes, "chatterino.ffzemotes", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoHelper, "chatterino.helper", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoImage, "chatterino.image", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoIrc, "chatterino.irc", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoIvr, "chatterino.ivr", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoMain, "chatterino.main", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoMessage, "chatterino.message", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoNativeMessage, "chatterino.nativemessage",
|
||||
logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoNotification, "chatterino.notification",
|
||||
logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoNuulsuploader, "chatterino.nuulsuploader",
|
||||
logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoPubsub, "chatterino.pubsub", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoStreamlink, "chatterino.streamlink", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoTokenizer, "chatterino.tokenizer", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoTwitch, "chatterino.twitch", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoUpdate, "chatterino.update", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoWebsocket, "chatterino.websocket", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoWidget, "chatterino.widget", logThreshold);
|
||||
Q_LOGGING_CATEGORY(chatterinoWindowmanager, "chatterino.windowmanager",
|
||||
logThreshold);
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoApp);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoArgs);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoBenchmark);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoBttv);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoCache);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoCommon);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoEmoji);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoFfzemotes);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoHelper);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoImage);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoIrc);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoIvr);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoMain);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoMessage);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoNativeMessage);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoNotification);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoNuulsuploader);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoPubsub);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoStreamlink);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoTokenizer);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoTwitch);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoUpdate);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoWebsocket);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoWidget);
|
||||
Q_DECLARE_LOGGING_CATEGORY(chatterinoWindowmanager);
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "common/WindowDescriptors.hpp"
|
||||
|
||||
#include "common/QLogging.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
@@ -126,7 +127,7 @@ WindowLayout WindowLayout::loadFromFile(const QString &path)
|
||||
{
|
||||
if (hasSetAMainWindow)
|
||||
{
|
||||
qDebug()
|
||||
qCDebug(chatterinoCommon)
|
||||
<< "Window Layout file contains more than one Main window "
|
||||
"- demoting to Popup type";
|
||||
type = WindowType::Popup;
|
||||
@@ -180,8 +181,9 @@ WindowLayout WindowLayout::loadFromFile(const QString &path)
|
||||
{
|
||||
if (hasSetASelectedTab)
|
||||
{
|
||||
qDebug() << "Window contains more than one selected tab - "
|
||||
"demoting to unselected";
|
||||
qCDebug(chatterinoCommon)
|
||||
<< "Window contains more than one selected tab - "
|
||||
"demoting to unselected";
|
||||
tab.selected_ = false;
|
||||
}
|
||||
hasSetASelectedTab = true;
|
||||
|
||||
Reference in New Issue
Block a user