Remove FMT dependency (#1472)

All occurrences of log() have been replaced with qDebug()

bonus meme: remove a bunch of std::string usages in the pubsub client

Fixes #1467
This commit is contained in:
pajlada
2020-01-03 20:51:37 +01:00
committed by GitHub
parent f02988b657
commit 3c8992cac1
57 changed files with 230 additions and 4920 deletions
+2 -3
View File
@@ -11,7 +11,6 @@
#include "controllers/notifications/NotificationController.hpp"
#include "controllers/pings/PingController.hpp"
#include "controllers/taggedusers/TaggedUsersController.hpp"
#include "debug/Log.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/chatterino/ChatterinoBadges.hpp"
@@ -158,11 +157,11 @@ void Application::initNm(Paths &paths)
void Application::initPubsub()
{
this->twitch.pubsub->signals_.whisper.sent.connect([](const auto &msg) {
log("WHISPER SENT LOL"); //
qDebug() << "WHISPER SENT LOL"; //
});
this->twitch.pubsub->signals_.whisper.received.connect([](const auto &msg) {
log("WHISPER RECEIVED LOL"); //
qDebug() << "WHISPER RECEIVED LOL"; //
});
this->twitch.pubsub->signals_.moderation.chatCleared.connect(
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#ifdef __cplusplus
# include <fmt/format.h>
# include <irccommand.h>
# include <ircconnection.h>
# include <rapidjson/document.h>
-1
View File
@@ -1,7 +1,6 @@
#include "common/Channel.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "singletons/Emotes.hpp"
-1
View File
@@ -6,7 +6,6 @@
#include "controllers/accounts/AccountController.hpp"
#include "controllers/commands/CommandController.hpp"
#include "debug/Benchmark.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/Emotes.hpp"
+1 -2
View File
@@ -1,6 +1,5 @@
#include "DownloadManager.hpp"
#include "debug/Log.hpp"
#include "singletons/Paths.hpp"
#include <QDesktopServices>
@@ -41,7 +40,7 @@ void DownloadManager::setFile(QString fileURL, const QString &channelName)
void DownloadManager::onDownloadProgress(qint64 bytesRead, qint64 bytesTotal)
{
log("Download progress: {}/{}", bytesRead, bytesTotal);
qDebug() << "Download progress: " << bytesRead << "/" << bytesTotal;
}
void DownloadManager::onFinished(QNetworkReply *reply)
+2 -3
View File
@@ -4,7 +4,6 @@
#include "common/NetworkResult.hpp"
#include "common/Outcome.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "debug/Log.hpp"
#include "singletons/Paths.hpp"
#include "util/DebugCount.hpp"
#include "util/PostToThread.hpp"
@@ -124,7 +123,7 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
if (reply == nullptr)
{
log("Unhandled request type");
qDebug() << "Unhandled request type";
return;
}
@@ -132,7 +131,7 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
{
QObject::connect(
data->timer_, &QTimer::timeout, worker, [reply, data]() {
log("Aborted!");
qDebug() << "Aborted!";
reply->abort();
if (data->onError_)
{
-1
View File
@@ -4,7 +4,6 @@
#include "common/Outcome.hpp"
#include "common/Version.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchCommon.hpp"
#include "singletons/Paths.hpp"
#include "util/DebugCount.hpp"
+3 -4
View File
@@ -1,7 +1,5 @@
#include "common/NetworkResult.hpp"
#include "debug/Log.hpp"
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
#include <QJsonDocument>
@@ -45,8 +43,9 @@ rapidjson::Document NetworkResult::parseRapidJson() const
if (result.Code() != rapidjson::kParseErrorNone)
{
log("JSON parse error: {} ({})",
rapidjson::GetParseError_En(result.Code()), result.Offset());
qDebug() << "JSON parse error:"
<< rapidjson::GetParseError_En(result.Code()) << "("
<< result.Offset() << ")";
return ret;
}
@@ -5,7 +5,6 @@
#include "controllers/accounts/AccountController.hpp"
#include "controllers/commands/Command.hpp"
#include "controllers/commands/CommandModel.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "messages/MessageElement.hpp"
@@ -4,7 +4,6 @@
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "controllers/notifications/NotificationModel.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchApi.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/Toasts.hpp"
@@ -147,12 +146,13 @@ void NotificationController::getFakeTwitchChannelLiveStatus(
TwitchApi::findUserId(channelName, [channelName, this](QString roomID) {
if (roomID.isEmpty())
{
log("[TwitchChannel:{}] Refreshing live status (Missing ID)",
channelName);
qDebug() << "[TwitchChannel" << channelName
<< "] Refreshing live status (Missing ID)";
removeFakeChannel(channelName);
return;
}
log("[TwitchChannel:{}] Refreshing live status", channelName);
qDebug() << "[TwitchChannel" << channelName
<< "] Refreshing live status";
QString url("https://api.twitch.tv/kraken/streams/" + roomID);
NetworkRequest::twitchRequest(url)
@@ -160,15 +160,15 @@ void NotificationController::getFakeTwitchChannelLiveStatus(
rapidjson::Document document = result.parseRapidJson();
if (!document.IsObject())
{
log("[TwitchChannel:refreshLiveStatus]root is not an "
"object");
qDebug() << "[TwitchChannel:refreshLiveStatus] root is not "
"an object";
return Failure;
}
if (!document.HasMember("stream"))
{
log("[TwitchChannel:refreshLiveStatus] Missing stream in "
"root");
qDebug() << "[TwitchChannel:refreshLiveStatus] Missing "
"stream in root";
return Failure;
}
+2 -1
View File
@@ -10,7 +10,8 @@ BenchmarkGuard::BenchmarkGuard(const QString &_name)
BenchmarkGuard::~BenchmarkGuard()
{
log("{} {} ms", this->name_, float(timer_.nsecsElapsed()) / 1000000.0f);
qDebug() << this->name_ << float(timer_.nsecsElapsed()) / 1000000.0f
<< "ms";
}
qreal BenchmarkGuard::getElapsedMs()
+1 -2
View File
@@ -1,7 +1,6 @@
#pragma once
#include "debug/Log.hpp"
#include <QDebug>
#include <QElapsedTimer>
#include <boost/noncopyable.hpp>
-29
View File
@@ -1,29 +0,0 @@
#pragma once
#include "util/Helpers.hpp"
#include <QDebug>
#include <QTime>
namespace chatterino {
template <typename... Args>
inline void log(const std::string &formatString, Args &&... args)
{
qDebug().noquote() << QTime::currentTime().toString("hh:mm:ss.zzz")
<< fS(formatString, std::forward<Args>(args)...).c_str();
}
template <typename... Args>
inline void log(const char *formatString, Args &&... args)
{
log(std::string(formatString), std::forward<Args>(args)...);
}
template <typename... Args>
inline void log(const QString &formatString, Args &&... args)
{
log(formatString.toStdString(), std::forward<Args>(args)...);
}
} // namespace chatterino
+4 -5
View File
@@ -14,7 +14,6 @@
#include "common/NetworkRequest.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "debug/Benchmark.hpp"
#include "debug/Log.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/WindowManager.hpp"
#include "util/DebugCount.hpp"
@@ -108,8 +107,8 @@ namespace detail {
if (reader.imageCount() == 0)
{
log("Error while reading image {}: '{}'", url.string,
reader.errorString());
qDebug() << "Error while reading image" << url.string << ": '"
<< reader.errorString() << "'";
return frames;
}
@@ -127,8 +126,8 @@ namespace detail {
if (frames.size() == 0)
{
log("Error while reading image {}: '{}'", url.string,
reader.errorString());
qDebug() << "Error while reading image" << url.string << ": '"
<< reader.errorString() << "'";
}
return frames;
-1
View File
@@ -5,7 +5,6 @@
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
#include "messages/ImageSet.hpp"
+5 -5
View File
@@ -1,7 +1,6 @@
#include "providers/emoji/Emojis.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "singletons/Settings.hpp"
@@ -132,8 +131,9 @@ void Emojis::loadEmojis()
if (result.Code() != rapidjson::kParseErrorNone)
{
log("JSON parse error: {} ({})",
rapidjson::GetParseError_En(result.Code()), result.Offset());
qDebug() << "JSON parse error:"
<< rapidjson::GetParseError_En(result.Code()) << "("
<< result.Offset() << ")";
return;
}
@@ -165,8 +165,8 @@ void Emojis::loadEmojis()
auto toneNameIt = toneNames.find(tone);
if (toneNameIt == toneNames.end())
{
log("Tone with key {} does not exist in tone names map",
tone);
qDebug() << "Tone with key" << tone.c_str()
<< "does not exist in tone names map";
continue;
}
+6 -6
View File
@@ -4,7 +4,6 @@
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
@@ -186,7 +185,8 @@ void FfzEmotes::loadChannel(
const QString &channelId, std::function<void(EmoteMap &&)> emoteCallback,
std::function<void(boost::optional<EmotePtr>)> modBadgeCallback)
{
log("[FFZEmotes] Reload FFZ Channel Emotes for channel {}\n", channelId);
qDebug() << "[FFZEmotes] Reload FFZ Channel Emotes for channel"
<< channelId;
NetworkRequest("https://api.frankerfacez.com/v1/room/id/" + channelId)
@@ -211,13 +211,13 @@ void FfzEmotes::loadChannel(
else if (result.status() == NetworkResult::timedoutStatus)
{
// TODO: Auto retry in case of a timeout, with a delay
log("Fetching FFZ emotes for channel {} failed due to timeout",
channelId);
qDebug() << "Fetching FFZ emotes for channel" << channelId
<< "failed due to timeout";
}
else
{
log("Error fetching FFZ emotes for channel {}, error {}",
channelId, result.status());
qDebug() << "Error fetching FFZ emotes for channel" << channelId
<< ", error" << result.status();
}
})
.execute();
+16 -16
View File
@@ -2,7 +2,6 @@
#include "common/Channel.hpp"
#include "common/Common.hpp"
#include "debug/Log.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
@@ -66,7 +65,7 @@ AbstractIrcServer::AbstractIrcServer()
if (!this->readConnection_->isConnected())
{
log("Trying to reconnect... {}", this->falloffCounter_);
qDebug() << "Trying to reconnect..." << this->falloffCounter_;
this->connect();
}
});
@@ -159,23 +158,24 @@ ChannelPtr AbstractIrcServer::getOrAddChannel(const QString &dirtyChannelName)
}
this->channels.insert(channelName, chan);
this->connections_.emplace_back(chan->destroyed.connect([this,
channelName] {
// fourtf: issues when the server itself is destroyed
this->connections_.emplace_back(
chan->destroyed.connect([this, channelName] {
// fourtf: issues when the server itself is destroyed
log("[AbstractIrcServer::addChannel] {} was destroyed", channelName);
this->channels.remove(channelName);
qDebug() << "[AbstractIrcServer::addChannel]" << channelName
<< "was destroyed";
this->channels.remove(channelName);
if (this->readConnection_)
{
this->readConnection_->sendRaw("PART #" + channelName);
}
if (this->readConnection_)
{
this->readConnection_->sendRaw("PART #" + channelName);
}
if (this->writeConnection_ && this->hasSeparateWriteConnection())
{
this->writeConnection_->sendRaw("PART #" + channelName);
}
}));
if (this->writeConnection_ && this->hasSeparateWriteConnection())
{
this->writeConnection_->sendRaw("PART #" + channelName);
}
}));
// join irc channel
{
+8 -13
View File
@@ -3,7 +3,6 @@
#include "Application.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/highlights/HighlightController.hpp"
#include "debug/Log.hpp"
#include "messages/LimitedQueue.hpp"
#include "messages/Message.hpp"
#include "providers/twitch/TwitchAccountManager.hpp"
@@ -235,9 +234,8 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
if (chan->isEmpty())
{
log("[IrcMessageHandler:handleClearChatMessage] Twitch channel {} not "
"found",
chanName);
qDebug() << "[IrcMessageHandler:handleClearChatMessage] Twitch channel"
<< chanName << "not found";
return;
}
@@ -300,10 +298,9 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
if (chan->isEmpty())
{
log("[IrcMessageHandler:handleClearMessageMessage] Twitch channel {} "
"not "
"found",
chanName);
qDebug()
<< "[IrcMessageHandler:handleClearMessageMessage] Twitch channel"
<< chanName << "not found";
return;
}
@@ -356,7 +353,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
{
auto app = getApp();
log("Received whisper!");
qDebug() << "Received whisper!";
MessageParseArgs args;
args.isReceivedWhisper = true;
@@ -568,10 +565,8 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
if (channel->isEmpty())
{
log("[IrcManager:handleNoticeMessage] Channel {} not found in "
"channel "
"manager ",
channelName);
qDebug() << "[IrcManager:handleNoticeMessage] Channel"
<< channelName << "not found in channel manager";
return;
}
+8 -10
View File
@@ -2,7 +2,6 @@
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchCommon.hpp"
#include <QJsonArray>
@@ -39,31 +38,30 @@ void PartialTwitchUser::getId(std::function<void(QString)> successCallback,
auto root = result.parseJson();
if (!root.value("users").isArray())
{
log("API Error while getting user id, users is not an array");
qDebug()
<< "API Error while getting user id, users is not an array";
return Failure;
}
auto users = root.value("users").toArray();
if (users.size() != 1)
{
log("API Error while getting user id, users array size is not "
"1");
qDebug() << "API Error while getting user id, users array size "
"is not 1";
return Failure;
}
if (!users[0].isObject())
{
log("API Error while getting user id, first user is not an "
"object");
qDebug() << "API Error while getting user id, first user is "
"not an object";
return Failure;
}
auto firstUser = users[0].toObject();
auto id = firstUser.value("_id");
if (!id.isString())
{
log("API Error: while getting user id, first user object `_id` "
"key "
"is not a "
"string");
qDebug() << "API Error: while getting user id, first user "
"object `_id` key is not a string";
return Failure;
}
successCallback(id.toString());
+69 -67
View File
@@ -1,8 +1,8 @@
#include "providers/twitch/PubsubClient.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/PubsubActions.hpp"
#include "providers/twitch/PubsubHelpers.hpp"
#include "util/Helpers.hpp"
#include "util/RapidjsonHelpers.hpp"
#include <rapidjson/error/en.h>
@@ -77,14 +77,14 @@ namespace detail {
return true;
}
void PubSubClient::unlistenPrefix(const std::string &prefix)
void PubSubClient::unlistenPrefix(const QString &prefix)
{
std::vector<std::string> topics;
std::vector<QString> topics;
for (auto it = this->listeners_.begin(); it != this->listeners_.end();)
{
const auto &listener = *it;
if (listener.topic.find(prefix) == 0)
if (listener.topic.startsWith(prefix))
{
topics.push_back(listener.topic);
it = this->listeners_.erase(it);
@@ -116,16 +116,14 @@ namespace detail {
{
assert(this->awaitingPong_);
log("Got pong!");
this->awaitingPong_ = false;
}
bool PubSubClient::isListeningToTopic(const std::string &payload)
bool PubSubClient::isListeningToTopic(const QString &topic)
{
for (const auto &listener : this->listeners_)
{
if (listener.topic == payload)
if (listener.topic == topic)
{
return true;
}
@@ -156,9 +154,8 @@ namespace detail {
if (self->awaitingPong_)
{
log("No pong response, disconnect!");
// TODO(pajlada): Label this connection as "disconnect
// me"
qDebug() << "No pong response, disconnect!";
// TODO(pajlada): Label this connection as "disconnect me"
}
});
@@ -181,7 +178,8 @@ namespace detail {
if (ec)
{
log("Error sending message {}: {}", payload, ec.message());
qDebug() << "Error sending message" << payload << ":"
<< ec.message().c_str();
// TODO(pajlada): Check which error code happened and maybe
// gracefully handle it
@@ -223,7 +221,7 @@ PubSub::PubSub()
if (!data.HasMember("args"))
{
log("Missing required args member");
qDebug() << "Missing required args member";
return;
}
@@ -231,13 +229,13 @@ PubSub::PubSub()
if (!args.IsArray())
{
log("args member must be an array");
qDebug() << "args member must be an array";
return;
}
if (args.Size() == 0)
{
log("Missing duration argument in slowmode on");
qDebug() << "Missing duration argument in slowmode on";
return;
}
@@ -245,7 +243,7 @@ PubSub::PubSub()
if (!durationArg.IsString())
{
log("Duration arg must be a string");
qDebug() << "Duration arg must be a string";
return;
}
@@ -338,7 +336,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
action.modded = false;
@@ -368,7 +366,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
action.modded = true;
@@ -417,7 +415,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@@ -454,7 +452,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@@ -485,7 +483,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@@ -516,7 +514,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@@ -568,7 +566,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@@ -597,7 +595,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@@ -626,7 +624,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@@ -655,7 +653,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@@ -685,7 +683,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@@ -738,7 +736,7 @@ void PubSub::addClient()
if (ec)
{
log("Unable to establish connection: {}", ec.message());
qDebug() << "Unable to establish connection:" << ec.message().c_str();
return;
}
@@ -753,20 +751,23 @@ void PubSub::start()
void PubSub::listenToWhispers(std::shared_ptr<TwitchAccount> account)
{
static const QString topicFormat("whispers.%1");
assert(account != nullptr);
std::string userID = account->getUserId().toStdString();
auto userID = account->getUserId();
log("Connection open!");
qDebug() << "Connection open!";
websocketpp::lib::error_code ec;
std::vector<std::string> topics({"whispers." + userID});
std::vector<QString> topics({topicFormat.arg(userID)});
this->listen(createListenMessage(topics, account));
if (ec)
{
log("Unable to send message to websocket server: {}", ec.message());
qDebug() << "Unable to send message to websocket server:"
<< ec.message().c_str();
return;
}
}
@@ -783,26 +784,26 @@ void PubSub::unlistenAllModerationActions()
void PubSub::listenToChannelModerationActions(
const QString &channelID, std::shared_ptr<TwitchAccount> account)
{
static const QString topicFormat("chat_moderator_actions.%1.%2");
assert(!channelID.isEmpty());
assert(account != nullptr);
QString userID = account->getUserId();
if (userID.isEmpty())
return;
std::string topic(fS("chat_moderator_actions.{}.{}", userID, channelID));
auto topic = topicFormat.arg(userID).arg(channelID);
if (this->isListeningToTopic(topic))
{
log("We are already listening to topic {}", topic);
return;
}
log("Listen to topic {}", topic);
qDebug() << "Listen to topic" << topic;
this->listenToTopic(topic, account);
}
void PubSub::listenToTopic(const std::string &topic,
void PubSub::listenToTopic(const QString &topic,
std::shared_ptr<TwitchAccount> account)
{
auto message = createListenMessage({topic}, account);
@@ -814,20 +815,19 @@ void PubSub::listen(rapidjson::Document &&msg)
{
if (this->tryListen(msg))
{
log("Successfully listened!");
return;
}
this->addClient();
log("Added to the back of the queue");
qDebug() << "Added to the back of the queue";
this->requests.emplace_back(
std::make_unique<rapidjson::Document>(std::move(msg)));
}
bool PubSub::tryListen(rapidjson::Document &msg)
{
log("tryListen with {} clients", this->clients.size());
qDebug() << "tryListen with" << this->clients.size() << "clients";
for (const auto &p : this->clients)
{
const auto &client = p.second;
@@ -840,7 +840,7 @@ bool PubSub::tryListen(rapidjson::Document &msg)
return false;
}
bool PubSub::isListeningToTopic(const std::string &topic)
bool PubSub::isListeningToTopic(const QString &topic)
{
for (const auto &p : this->clients)
{
@@ -865,24 +865,24 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
if (!res)
{
log("Error parsing message '{}' from PubSub: {}", payload,
rapidjson::GetParseError_En(res.Code()));
qDebug() << "Error parsing message '" << payload.c_str()
<< "' from PubSub:" << rapidjson::GetParseError_En(res.Code());
return;
}
if (!msg.IsObject())
{
log("Error parsing message '{}' from PubSub. Root object is not an "
"object",
payload);
qDebug() << "Error parsing message '" << payload.c_str()
<< "' from PubSub. Root object is not an "
"object";
return;
}
std::string type;
QString type;
if (!rj::getSafe(msg, "type", type))
{
log("Missing required string member `type` in message root");
qDebug() << "Missing required string member `type` in message root";
return;
}
@@ -894,7 +894,7 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
{
if (!msg.HasMember("data"))
{
log("Missing required object member `data` in message root");
qDebug() << "Missing required object member `data` in message root";
return;
}
@@ -902,7 +902,7 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
if (!data.IsObject())
{
log("Member `data` must be an object");
qDebug() << "Member `data` must be an object";
return;
}
@@ -922,7 +922,7 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
}
else
{
log("Unknown message type: {}", type);
qDebug() << "Unknown message type:" << type;
}
}
@@ -983,7 +983,7 @@ PubSub::WebsocketContextPtr PubSub::onTLSInit(websocketpp::connection_hdl hdl)
}
catch (const std::exception &e)
{
log("Exception caught in OnTLSInit: {}", e.what());
qDebug() << "Exception caught in OnTLSInit:" << e.what();
}
return ctx;
@@ -991,21 +991,21 @@ PubSub::WebsocketContextPtr PubSub::onTLSInit(websocketpp::connection_hdl hdl)
void PubSub::handleListenResponse(const rapidjson::Document &msg)
{
std::string error;
QString error;
if (rj::getSafe(msg, "error", error))
{
std::string nonce;
QString nonce;
rj::getSafe(msg, "nonce", nonce);
if (error.empty())
if (error.isEmpty())
{
log("Successfully listened to nonce {}", nonce);
qDebug() << "Successfully listened to nonce" << nonce;
// Nothing went wrong
return;
}
log("PubSub error: {} on nonce {}", error, nonce);
qDebug() << "PubSub error:" << error << "on nonce" << nonce;
return;
}
}
@@ -1016,7 +1016,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (!rj::getSafe(outerData, "topic", topic))
{
log("Missing required string member `topic` in outerData");
qDebug() << "Missing required string member `topic` in outerData";
return;
}
@@ -1024,7 +1024,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (!rj::getSafe(outerData, "message", payload))
{
log("Expected string message in outerData");
qDebug() << "Expected string message in outerData";
return;
}
@@ -1034,8 +1034,8 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (!res)
{
log("Error parsing message '{}' from PubSub: {}", payload,
rapidjson::GetParseError_En(res.Code()));
qDebug() << "Error parsing message '" << payload.c_str()
<< "' from PubSub:" << rapidjson::GetParseError_En(res.Code());
return;
}
@@ -1045,7 +1045,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (!rj::getSafe(msg, "type", whisperType))
{
log("Bad whisper data");
qDebug() << "Bad whisper data";
return;
}
@@ -1063,7 +1063,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
}
else
{
log("Invalid whisper type: {}", whisperType);
qDebug() << "Invalid whisper type:" << whisperType.c_str();
assert(false);
return;
}
@@ -1078,7 +1078,8 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (!rj::getSafe(data, "moderation_action", moderationAction))
{
log("Missing moderation action in data: {}", rj::stringify(data));
qDebug() << "Missing moderation action in data:"
<< rj::stringify(data).c_str();
return;
}
@@ -1086,7 +1087,8 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (handlerIt == this->moderationActionHandlers.end())
{
log("No handler found for moderation action {}", moderationAction);
qDebug() << "No handler found for moderation action"
<< moderationAction.c_str();
return;
}
@@ -1095,16 +1097,16 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
}
else
{
log("Unknown topic: {}", topic);
qDebug() << "Unknown topic:" << topic;
return;
}
}
void PubSub::runThread()
{
log("Start pubsub manager thread");
qDebug() << "Start pubsub manager thread";
this->websocketClient.run();
log("Done with pubsub manager thread");
qDebug() << "Done with pubsub manager thread";
}
} // namespace chatterino
+5 -6
View File
@@ -15,7 +15,6 @@
#include <map>
#include <memory>
#include <set>
#include <string>
#include <thread>
#include <unordered_map>
#include <vector>
@@ -33,7 +32,7 @@ using WebsocketErrorCode = websocketpp::lib::error_code;
namespace detail {
struct Listener {
std::string topic;
QString topic;
bool authed;
bool persistent;
bool confirmed = false;
@@ -49,11 +48,11 @@ namespace detail {
void stop();
bool listen(rapidjson::Document &message);
void unlistenPrefix(const std::string &prefix);
void unlistenPrefix(const QString &prefix);
void handlePong();
bool isListeningToTopic(const std::string &topic);
bool isListeningToTopic(const QString &topic);
private:
void ping();
@@ -135,13 +134,13 @@ public:
std::vector<std::unique_ptr<rapidjson::Document>> requests;
private:
void listenToTopic(const std::string &topic,
void listenToTopic(const QString &topic,
std::shared_ptr<TwitchAccount> account);
void listen(rapidjson::Document &&msg);
bool tryListen(rapidjson::Document &msg);
bool isListeningToTopic(const std::string &topic);
bool isListeningToTopic(const QString &topic);
void addClient();
+3 -5
View File
@@ -46,9 +46,8 @@ bool getTargetUser(const rapidjson::Value &data, ActionUser &user)
return rj::getSafe(data, "target_user_id", user.id);
}
rapidjson::Document createListenMessage(
const std::vector<std::string> &topicsVec,
std::shared_ptr<TwitchAccount> account)
rapidjson::Document createListenMessage(const std::vector<QString> &topicsVec,
std::shared_ptr<TwitchAccount> account)
{
rapidjson::Document msg(rapidjson::kObjectType);
auto &a = msg.GetAllocator();
@@ -75,8 +74,7 @@ rapidjson::Document createListenMessage(
return msg;
}
rapidjson::Document createUnlistenMessage(
const std::vector<std::string> &topicsVec)
rapidjson::Document createUnlistenMessage(const std::vector<QString> &topicsVec)
{
rapidjson::Document msg(rapidjson::kObjectType);
auto &a = msg.GetAllocator();
+5 -7
View File
@@ -3,7 +3,6 @@
#include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <memory>
#include "debug/Log.hpp"
#include "util/RapidjsonHelpers.hpp"
namespace chatterino {
@@ -18,11 +17,10 @@ bool getCreatedByUser(const rapidjson::Value &data, ActionUser &user);
bool getTargetUser(const rapidjson::Value &data, ActionUser &user);
rapidjson::Document createListenMessage(
const std::vector<std::string> &topicsVec,
std::shared_ptr<TwitchAccount> account);
rapidjson::Document createListenMessage(const std::vector<QString> &topicsVec,
std::shared_ptr<TwitchAccount> account);
rapidjson::Document createUnlistenMessage(
const std::vector<std::string> &topicsVec);
const std::vector<QString> &topicsVec);
// Create timer using given ioService
template <typename Duration, typename Callback>
@@ -35,7 +33,7 @@ void runAfter(boost::asio::io_service &ioService, Duration duration,
timer->async_wait([timer, cb](const boost::system::error_code &ec) {
if (ec)
{
log("Error in runAfter: {}", ec.message());
qDebug() << "Error in runAfter:" << ec.message().c_str();
return;
}
@@ -53,7 +51,7 @@ void runAfter(std::shared_ptr<boost::asio::steady_timer> timer,
timer->async_wait([timer, cb](const boost::system::error_code &ec) {
if (ec)
{
log("Error in runAfter: {}", ec.message());
qDebug() << "Error in runAfter:" << ec.message().c_str();
return;
}
+17 -15
View File
@@ -6,7 +6,6 @@
#include "common/Env.hpp"
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/PartialTwitchUser.hpp"
#include "providers/twitch/TwitchCommon.hpp"
#include "singletons/Emotes.hpp"
@@ -134,8 +133,8 @@ void TwitchAccount::loadIgnores()
TwitchUser ignoredUser;
if (!rj::getSafe(userIt->value, ignoredUser))
{
log("Error parsing twitch user JSON {}",
rj::stringify(userIt->value));
qDebug() << "Error parsing twitch user JSON"
<< rj::stringify(userIt->value).c_str();
continue;
}
@@ -345,14 +344,14 @@ std::set<TwitchUser> TwitchAccount::getIgnores() const
void TwitchAccount::loadEmotes()
{
log("Loading Twitch emotes for user {}", this->getUserName());
qDebug() << "Loading Twitch emotes for user" << this->getUserName();
const auto &clientID = this->getOAuthClient();
const auto &oauthToken = this->getOAuthToken();
if (clientID.isEmpty() || oauthToken.isEmpty())
{
log("Missing Client ID or OAuth token");
qDebug() << "Missing Client ID or OAuth token";
return;
}
@@ -363,7 +362,7 @@ void TwitchAccount::loadEmotes()
.authorizeTwitchV5(this->getOAuthClient(), this->getOAuthToken())
.onError([=](NetworkResult result) {
log("[TwitchAccount::loadEmotes] Error {}", result.status());
qDebug() << "[TwitchAccount::loadEmotes] Error" << result.status();
if (result.status() == 203)
{
// onFinished(FollowResult_NotFollowing);
@@ -402,7 +401,8 @@ void TwitchAccount::autoModAllow(const QString msgID)
.authorizeTwitchV5(this->getOAuthClient(), this->getOAuthToken())
.onError([=](NetworkResult result) {
log("[TwitchAccounts::autoModAllow] Error {}", result.status());
qDebug() << "[TwitchAccounts::autoModAllow] Error"
<< result.status();
})
.execute();
}
@@ -421,7 +421,8 @@ void TwitchAccount::autoModDeny(const QString msgID)
.authorizeTwitchV5(this->getOAuthClient(), this->getOAuthToken())
.onError([=](NetworkResult result) {
log("[TwitchAccounts::autoModDeny] Error {}", result.status());
qDebug() << "[TwitchAccounts::autoModDeny] Error"
<< result.status();
})
.execute();
}
@@ -436,7 +437,7 @@ void TwitchAccount::parseEmotes(const rapidjson::Document &root)
auto emoticonSets = root.FindMember("emoticon_sets");
if (emoticonSets == root.MemberEnd() || !emoticonSets->value.IsObject())
{
log("No emoticon_sets in load emotes response");
qDebug() << "No emoticon_sets in load emotes response";
return;
}
@@ -452,21 +453,21 @@ void TwitchAccount::parseEmotes(const rapidjson::Document &root)
{
if (!emoteJSON.IsObject())
{
log("Emote value was invalid");
qDebug() << "Emote value was invalid";
return;
}
uint64_t idNumber;
if (!rj::getSafe(emoteJSON, "id", idNumber))
{
log("No ID key found in Emote value");
qDebug() << "No ID key found in Emote value";
return;
}
QString _code;
if (!rj::getSafe(emoteJSON, "code", _code))
{
log("No code key found in Emote value");
qDebug() << "No code key found in Emote value";
return;
}
@@ -489,7 +490,7 @@ void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
{
if (!emoteSet)
{
log("null emote set sent");
qDebug() << "null emote set sent";
return;
}
@@ -505,7 +506,8 @@ void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
NetworkRequest(Env::get().twitchEmoteSetResolverUrl.arg(emoteSet->key))
.cache()
.onError([](NetworkResult result) {
log("Error code {} while loading emote set data", result.status());
qDebug() << "Error code" << result.status()
<< "while loading emote set data";
})
.onSuccess([emoteSet](auto result) -> Outcome {
auto root = result.parseRapidJson();
@@ -527,7 +529,7 @@ void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
return Failure;
}
log("Loaded twitch emote set data for {}!", emoteSet->key);
qDebug() << "Loaded twitch emote set data for" << emoteSet->key;
auto name = channelName;
name.detach();
+11 -13
View File
@@ -1,7 +1,6 @@
#include "providers/twitch/TwitchAccountManager.hpp"
#include "common/Common.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "providers/twitch/TwitchCommon.hpp"
@@ -103,23 +102,23 @@ void TwitchAccountManager::reloadUsers()
switch (this->addUser(userData))
{
case AddUserResponse::UserAlreadyExists: {
log("User {} already exists", userData.username);
qDebug() << "User" << userData.username << "already exists";
// Do nothing
}
break;
case AddUserResponse::UserValuesUpdated: {
log("User {} already exists, and values updated!",
userData.username);
qDebug() << "User" << userData.username
<< "already exists, and values updated!";
if (userData.username == this->getCurrent()->getUserName())
{
log("It was the current user, so we need to reconnect "
"stuff!");
qDebug() << "It was the current user, so we need to "
"reconnect stuff!";
this->currentUserChanged.invoke();
}
}
break;
case AddUserResponse::UserAdded: {
log("Added user {}", userData.username);
qDebug() << "Added user" << userData.username;
listUpdated = true;
}
break;
@@ -140,15 +139,12 @@ void TwitchAccountManager::load()
auto user = this->findUserByUsername(newUsername);
if (user)
{
log("[AccountManager:currentUsernameChanged] User successfully "
"updated to {}",
newUsername);
qDebug() << "Twitch user updated to" << newUsername;
this->currentUser_ = user;
}
else
{
log("[AccountManager:currentUsernameChanged] User successfully "
"updated to anonymous");
qDebug() << "Twitch user updated to anonymous";
this->currentUser_ = this->anonymousUser_;
}
@@ -170,11 +166,13 @@ bool TwitchAccountManager::isLoggedIn() const
bool TwitchAccountManager::removeUser(TwitchAccount *account)
{
static const QString accountFormat("/accounts/uid%1");
auto userID(account->getUserId());
if (!userID.isEmpty())
{
pajlada::Settings::SettingManager::removeSetting(
fS("/accounts/uid{}", userID));
accountFormat.arg(userID).toStdString());
}
if (account->getUserName() == this->currentUsername)
+10 -12
View File
@@ -2,7 +2,6 @@
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchCommon.hpp"
#include <QString>
@@ -23,22 +22,23 @@ void TwitchApi::findUserId(const QString user,
auto root = result.parseJson();
if (!root.value("users").isArray())
{
log("API Error while getting user id, users is not an array");
qDebug()
<< "API Error while getting user id, users is not an array";
successCallback("");
return Failure;
}
auto users = root.value("users").toArray();
if (users.size() != 1)
{
log("API Error while getting user id, users array size is not "
"1");
qDebug() << "API Error while getting user id, users array size "
"is not 1";
successCallback("");
return Failure;
}
if (!users[0].isObject())
{
log("API Error while getting user id, first user is not an "
"object");
qDebug() << "API Error while getting user id, first user is "
"not an object";
successCallback("");
return Failure;
}
@@ -46,10 +46,8 @@ void TwitchApi::findUserId(const QString user,
auto id = firstUser.value("_id");
if (!id.isString())
{
log("API Error: while getting user id, first user object `_id` "
"key "
"is not a "
"string");
qDebug() << "API Error: while getting user id, first user "
"object `_id` key is not a string";
successCallback("");
return Failure;
}
@@ -73,8 +71,8 @@ void TwitchApi::findUserName(const QString userid,
auto name = root.value("name");
if (!name.isString())
{
log("API Error: while getting user name, `name` is not a "
"string");
qDebug() << "API Error: while getting user name, `name` is not "
"a string";
successCallback("");
return Failure;
}
-1
View File
@@ -7,7 +7,6 @@
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
namespace chatterino {
+12 -11
View File
@@ -6,7 +6,6 @@
#include "common/NetworkRequest.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/notifications/NotificationController.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/bttv/LoadBttvChannelEmote.hpp"
@@ -92,7 +91,7 @@ TwitchChannel::TwitchChannel(const QString &name,
, mod_(false)
, titleRefreshedTime_(QTime::currentTime().addSecs(-TITLE_REFRESH_PERIOD))
{
log("[TwitchChannel:{}] Opened", name);
qDebug() << "[TwitchChannel" << name << "] Opened";
this->liveStatusChanged.connect([this]() {
if (this->isLive() == 1)
@@ -194,7 +193,8 @@ void TwitchChannel::sendMessage(const QString &message)
return;
}
log("[TwitchChannel:{}] Send message: {}", this->getName(), message);
qDebug() << "[TwitchChannel" << this->getName()
<< "] Send message:" << message;
// Do last message processing
QString parsedMessage = app->emotes->emojis.replaceShortCodes(message);
@@ -491,8 +491,8 @@ void TwitchChannel::refreshLiveStatus()
if (roomID.isEmpty())
{
log("[TwitchChannel:{}] Refreshing live status (Missing ID)",
this->getName());
qDebug() << "[TwitchChannel" << this->getName()
<< "] Refreshing live status (Missing ID)";
this->setLive(false);
return;
}
@@ -517,13 +517,13 @@ Outcome TwitchChannel::parseLiveStatus(const rapidjson::Document &document)
{
if (!document.IsObject())
{
log("[TwitchChannel:refreshLiveStatus] root is not an object");
qDebug() << "[TwitchChannel:refreshLiveStatus] root is not an object";
return Failure;
}
if (!document.HasMember("stream"))
{
log("[TwitchChannel:refreshLiveStatus] Missing stream in root");
qDebug() << "[TwitchChannel:refreshLiveStatus] Missing stream in root";
return Failure;
}
@@ -539,7 +539,8 @@ Outcome TwitchChannel::parseLiveStatus(const rapidjson::Document &document)
if (!stream.HasMember("viewers") || !stream.HasMember("game") ||
!stream.HasMember("channel") || !stream.HasMember("created_at"))
{
log("[TwitchChannel:refreshLiveStatus] Missing members in stream");
qDebug()
<< "[TwitchChannel:refreshLiveStatus] Missing members in stream";
this->setLive(false);
return Failure;
}
@@ -548,8 +549,8 @@ Outcome TwitchChannel::parseLiveStatus(const rapidjson::Document &document)
if (!streamChannel.IsObject() || !streamChannel.HasMember("status"))
{
log("[TwitchChannel:refreshLiveStatus] Missing member \"status\" in "
"channel");
qDebug() << "[TwitchChannel:refreshLiveStatus] Missing member "
"\"status\" in channel";
return Failure;
}
@@ -836,7 +837,7 @@ boost::optional<CheerEmote> TwitchChannel::cheerEmote(const QString &string)
int bitAmount = amount.toInt(&ok);
if (!ok)
{
log("Error parsing bit amount in cheerEmote");
qDebug() << "Error parsing bit amount in cheerEmote";
}
for (const auto &emote : set.cheerEmotes)
{
-1
View File
@@ -2,7 +2,6 @@
#include "common/NetworkRequest.hpp"
#include "debug/Benchmark.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
#include "util/RapidjsonHelpers.hpp"
+1 -2
View File
@@ -1,5 +1,4 @@
#include "providers/twitch/TwitchHelpers.hpp"
#include "debug/Log.hpp"
namespace chatterino {
@@ -7,7 +6,7 @@ bool trimChannelName(const QString &channelName, QString &outChannelName)
{
if (channelName.length() < 2)
{
log("channel name length below 2");
qDebug() << "channel name length below 2";
return false;
}
+16 -20
View File
@@ -5,7 +5,6 @@
#include "controllers/highlights/HighlightController.hpp"
#include "controllers/ignores/IgnoreController.hpp"
#include "controllers/pings/PingController.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "providers/chatterino/ChatterinoBadges.hpp"
#include "providers/twitch/TwitchBadges.hpp"
@@ -90,8 +89,6 @@ namespace {
QStringList parts = badgeInfo.split('/');
if (parts.size() != 2)
{
log("Skipping badge-info because it split weird: {}",
badgeInfo);
continue;
}
@@ -110,7 +107,6 @@ namespace {
QStringList parts = badge.split('/');
if (parts.size() != 2)
{
log("Skipping badge because it split weird: {}", badge);
continue;
}
@@ -159,8 +155,8 @@ bool TwitchMessageBuilder::isIgnored() const
{
if (phrase.isBlock() && phrase.isMatch(this->originalMessage_))
{
log("Blocking message because it contains ignored phrase {}",
phrase.getPattern());
qDebug() << "Blocking message because it contains ignored phrase"
<< phrase.getPattern();
return true;
}
}
@@ -190,8 +186,8 @@ bool TwitchMessageBuilder::isIgnored() const
case ShowIgnoredUsersMessages::Never:
break;
}
log("Blocking message because it's from blocked user {}",
user.name);
qDebug() << "Blocking message because it's from blocked user"
<< user.name;
return true;
}
}
@@ -427,8 +423,8 @@ void TwitchMessageBuilder::addWords(
auto emoteImage = std::get<1>(*currentTwitchEmote);
if (emoteImage == nullptr)
{
log("emoteImage nullptr {}",
std::get<2>(*currentTwitchEmote).string);
qDebug() << "emoteImage nullptr"
<< std::get<2>(*currentTwitchEmote).string;
}
this->emplace<EmoteElement>(emoteImage,
MessageElementFlag::TwitchEmote);
@@ -771,7 +767,7 @@ void TwitchMessageBuilder::runIgnoreReplaces(
{
if (std::get<1>(*copy) == nullptr)
{
log("remem nullptr {}", std::get<2>(*copy).string);
qDebug() << "remem nullptr" << std::get<2>(*copy).string;
}
}
std::vector<std::tuple<int, EmotePtr, EmoteName>> v(
@@ -809,7 +805,7 @@ void TwitchMessageBuilder::runIgnoreReplaces(
{
if (emote.second == nullptr)
{
log("emote null {}", emote.first.string);
qDebug() << "emote null" << emote.first.string;
}
twitchEmotes.push_back(std::tuple<int, EmotePtr, EmoteName>{
startIndex + pos, emote.second, emote.first});
@@ -872,7 +868,7 @@ void TwitchMessageBuilder::runIgnoreReplaces(
{
if (std::get<1>(tup) == nullptr)
{
log("v nullptr {}", std::get<2>(tup).string);
qDebug() << "v nullptr" << std::get<2>(tup).string;
continue;
}
QRegularExpression emoteregex(
@@ -941,7 +937,7 @@ void TwitchMessageBuilder::runIgnoreReplaces(
{
if (std::get<1>(tup) == nullptr)
{
log("v nullptr {}", std::get<2>(tup).string);
qDebug() << "v nullptr" << std::get<2>(tup).string;
continue;
}
QRegularExpression emoteregex(
@@ -991,8 +987,8 @@ void TwitchMessageBuilder::parseHighlights()
{
continue;
}
log("Highlight because user {} sent a message",
this->ircMessage->nick());
qDebug() << "Highlight because user" << this->ircMessage->nick()
<< "sent a message";
if (!this->highlightVisual_)
{
this->highlightVisual_ = true;
@@ -1044,8 +1040,8 @@ void TwitchMessageBuilder::parseHighlights()
continue;
}
log("Highlight because {} matches {}", this->originalMessage_,
highlight.getPattern());
qDebug() << "Highlight because" << this->originalMessage_ << "matches"
<< highlight.getPattern();
if (!this->highlightVisual_)
{
this->highlightVisual_ = true;
@@ -1130,7 +1126,7 @@ void TwitchMessageBuilder::appendTwitchEmote(
start, app->emotes->twitch.getOrCreateEmote(id, name), name};
if (std::get<1>(tup) == nullptr)
{
log("nullptr {}", std::get<2>(tup).string);
qDebug() << "nullptr" << std::get<2>(tup).string;
}
vec.push_back(std::move(tup));
}
@@ -1216,7 +1212,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
auto badgeEmote = this->getTwitchBadge(badge);
if (!badgeEmote)
{
log("No channel/global variant found {}", badge.key_);
qDebug() << "No channel/global variant found" << badge.key_;
continue;
}
auto tooltip = (*badgeEmote)->tooltip.string;
-1
View File
@@ -1,7 +1,6 @@
#include "singletons/Logging.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
-1
View File
@@ -1,7 +1,6 @@
#include "singletons/Settings.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Resources.hpp"
#include "singletons/WindowManager.hpp"
+2 -3
View File
@@ -13,7 +13,6 @@
#include "Application.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "debug/Log.hpp"
#include "messages/MessageElement.hpp"
#include "providers/irc/Irc2.hpp"
#include "providers/irc/IrcChannel2.hpp"
@@ -264,7 +263,7 @@ Window *WindowManager::windowAt(int index)
{
return nullptr;
}
log("getting window at bad index {}", index);
qDebug() << "getting window at bad index" << index;
return this->windows_.at(index);
}
@@ -432,7 +431,7 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
void WindowManager::save()
{
log("[WindowManager] Saving");
qDebug() << "[WindowManager] Saving";
assertInGuiThread();
QJsonDocument document;
+2 -3
View File
@@ -1,7 +1,6 @@
#include "LoggingChannel.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
@@ -64,13 +63,13 @@ void LoggingChannel::openLogFile()
if (!QDir().mkpath(directory))
{
log("Unable to create logging path");
qDebug() << "Unable to create logging path";
return;
}
// Open file handle to log file of current date
QString fileName = directory + QDir::separator() + baseFileName;
log("Logging to {}", fileName);
qDebug() << "Logging to" << fileName;
this->fileHandle.setFileName(fileName);
this->fileHandle.open(QIODevice::Append);
-17
View File
@@ -1,16 +1,9 @@
#pragma once
#include <fmt/format.h>
#include <QString>
namespace chatterino {
template <typename... Args>
auto fS(Args &&... args)
{
return fmt::format(std::forward<Args>(args)...);
}
QString generateUuid();
QString formatRichLink(const QString &url, bool file = false);
@@ -21,13 +14,3 @@ QString formatRichNamedLink(const QString &url, const QString &name,
QString shortenString(const QString &str, unsigned maxWidth = 50);
} // namespace chatterino
namespace fmt {
// format_arg for QString
inline void format_arg(BasicFormatter<char> &f, const char *&, const QString &v)
{
f.writer().write("{}", v.toStdString());
}
} // namespace fmt
-2
View File
@@ -5,8 +5,6 @@
#include <QSettings>
#include <QVariant>
#include "debug/Log.hpp"
namespace chatterino {
namespace {
#ifdef Q_OS_WIN
+2 -3
View File
@@ -1,7 +1,6 @@
#include "util/StreamLink.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Settings.hpp"
#include "util/Helpers.hpp"
#include "widgets/dialogs/QualityPopup.hpp"
@@ -92,7 +91,7 @@ namespace {
}
else
{
log("Error occured {}", err);
qDebug() << "Error occured" << err;
}
p->deleteLater();
@@ -119,7 +118,7 @@ void getStreamQualities(const QString &channelURL,
[=](int res) {
if (res != 0)
{
log("Got error code {}", res);
qDebug() << "Got error code" << res;
// return;
}
QString lastLine = QString(p->readAllStandardOutput());
-1
View File
@@ -1,5 +1,4 @@
#include "widgets/AccountSwitchPopup.hpp"
#include "debug/Log.hpp"
#include "widgets/dialogs/SettingsDialog.hpp"
#include <QHBoxLayout>
-1
View File
@@ -2,7 +2,6 @@
#include "BaseSettings.hpp"
#include "BaseTheme.hpp"
#include "debug/Log.hpp"
#include "widgets/BaseWindow.hpp"
#include <QChildEvent>
+2 -3
View File
@@ -3,7 +3,6 @@
#include "BaseSettings.hpp"
#include "BaseTheme.hpp"
#include "boost/algorithm/algorithm.hpp"
#include "debug/Log.hpp"
#include "util/PostToThread.hpp"
#include "util/Shortcut.hpp"
#include "util/WindowsHelper.hpp"
@@ -385,7 +384,7 @@ void BaseWindow::mousePressEvent(QMouseEvent *event)
if (!recursiveCheckMouseTracking(widget))
{
log("Start moving");
qDebug() << "Start moving";
this->moving = true;
}
}
@@ -402,7 +401,7 @@ void BaseWindow::mouseReleaseEvent(QMouseEvent *event)
{
if (this->moving)
{
log("Stop moving");
qDebug() << "Stop moving";
this->moving = false;
}
}
-1
View File
@@ -1,7 +1,6 @@
#include "widgets/Notebook.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"
+1 -1
View File
@@ -65,7 +65,7 @@ namespace {
// messageBox.setIcon(QMessageBox::Information);
// messageBox.setText("Successfully logged in with user <b>" +
// qS(username) + "</b>!");
auto basePath = fS("/accounts/uid{}", userID);
std::string basePath = "/accounts/uid" + userID.toStdString();
pajlada::Settings::Setting<QString>::set(basePath + "/username",
username);
pajlada::Settings::Setting<QString>::set(basePath + "/userID", userID);
+1 -2
View File
@@ -3,7 +3,6 @@
#include "IrcMessage"
#include "common/Channel.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "providers/twitch/PartialTwitchUser.hpp"
#include "providers/twitch/TwitchChannel.hpp"
@@ -70,7 +69,7 @@ void LogsPopup::getLogs()
return;
}
log("Unable to get logs, no channel name or something specified");
qDebug() << "Unable to get logs, no channel name or something specified";
}
void LogsPopup::setMessages(std::vector<MessagePtr> &messages)
+1 -2
View File
@@ -1,5 +1,4 @@
#include "QualityPopup.hpp"
#include "debug/Log.hpp"
#include "util/StreamLink.hpp"
namespace chatterino {
@@ -50,7 +49,7 @@ void QualityPopup::okButtonClicked()
}
catch (const Exception &ex)
{
log("Exception caught trying to open streamlink: {}", ex.what());
qDebug() << "Exception caught trying to open streamlink:" << ex.what();
}
this->close();
+2 -4
View File
@@ -16,7 +16,6 @@
#include "common/Common.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "debug/Benchmark.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/Message.hpp"
@@ -740,9 +739,8 @@ void ChannelView::messageReplaced(size_t index, MessagePtr &replacement)
auto snapshot = this->messages_.getSnapshot();
if (index >= snapshot.size())
{
log("Tried to replace out of bounds message. Index: {}. "
"Length: {}",
index, snapshot.size());
qDebug() << "Tried to replace out of bounds message. Index:" << index
<< ". Length:" << snapshot.size();
return;
}
-1
View File
@@ -2,7 +2,6 @@
#include "Application.hpp"
#include "common/Common.hpp"
#include "debug/Log.hpp"
#include "singletons/Fonts.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
+1 -4
View File
@@ -2,7 +2,6 @@
#include "common/Modes.hpp"
#include "common/Version.hpp"
#include "debug/Log.hpp"
#include "util/LayoutCreator.hpp"
#include "util/RemoveScrollAreaBackground.hpp"
#include "widgets/helper/SignalLabel.hpp"
@@ -102,8 +101,6 @@ AboutPage::AboutPage()
":/licenses/qt_lgpl-3.0.txt");
addLicense(form.getElement(), "Boost", "https://www.boost.org/",
":/licenses/boost_boost.txt");
addLicense(form.getElement(), "Fmt", "http://fmtlib.net/",
":/licenses/fmt_bsd2.txt");
addLicense(form.getElement(), "LibCommuni",
"https://github.com/communi/libcommuni",
":/licenses/libcommuni_BSD3.txt");
@@ -166,7 +163,7 @@ AboutPage::AboutPage()
if (contributorParts.size() != 4)
{
log("Missing parts in line '{}'", line);
qDebug() << "Missing parts in line" << line;
continue;
}
@@ -5,7 +5,6 @@
#include "controllers/highlights/HighlightController.hpp"
#include "controllers/highlights/HighlightModel.hpp"
#include "controllers/highlights/UserHighlightModel.hpp"
#include "debug/Log.hpp"
#include "singletons/Settings.hpp"
#include "util/LayoutCreator.hpp"
#include "util/StandardItemHelper.hpp"
+1 -2
View File
@@ -3,7 +3,6 @@
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/EmoteValue.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
@@ -530,7 +529,7 @@ void Split::openInStreamlink()
}
catch (const Exception &ex)
{
log("Error in doOpenStreamlink: {}", ex.what());
qDebug() << "Error in doOpenStreamlink:" << ex.what();
}
}