fix: use qlogging in eventsub lib (through a hoop) (#6161)

This commit is contained in:
pajlada
2025-04-19 17:10:12 +02:00
committed by GitHub
parent 9d557146b4
commit 1f10935d78
14 changed files with 134 additions and 14 deletions
+29 -2
View File
@@ -40,8 +40,35 @@ const auto &LOG = chatterinoTwitchEventSub;
namespace chatterino::eventsub {
class QLogProxy : public lib::Logger
{
public:
QLogProxy(const QLoggingCategory &loggingCategory_)
: loggingCategory(loggingCategory_)
{
}
void debug(std::string_view msg) override
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
qCDebug(this->loggingCategory).noquote() << msg;
#endif
}
void warn(std::string_view msg) override
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
qCWarning(this->loggingCategory).noquote() << msg;
#endif
}
private:
const QLoggingCategory &loggingCategory;
};
Controller::Controller()
: userAgent(QStringLiteral("chatterino/%1 (%2)")
: logProxy(std::shared_ptr<lib::Logger>(new QLogProxy(LOG())))
, userAgent(QStringLiteral("chatterino/%1 (%2)")
.arg(Version::instance().version(),
Version::instance().commitHash())
.toUtf8()
@@ -456,7 +483,7 @@ void Controller::createConnection(std::string host, std::string port,
}
auto connection = std::make_shared<lib::Session>(
this->ioContext, sslContext, std::move(listener));
this->ioContext, sslContext, std::move(listener), this->logProxy);
this->registerConnection(connection);
@@ -2,6 +2,7 @@
#include "providers/twitch/eventsub/SubscriptionHandle.hpp"
#include "providers/twitch/eventsub/SubscriptionRequest.hpp"
#include "twitch-eventsub-ws/logger.hpp"
#include "twitch-eventsub-ws/session.hpp"
#include "util/ExponentialBackoff.hpp"
#include "util/ThreadGuard.hpp"
@@ -91,6 +92,8 @@ private:
void clearConnections();
std::shared_ptr<lib::Logger> logProxy;
const std::string userAgent;
std::string eventSubHost;
+2
View File
@@ -132,6 +132,8 @@ AboutPage::AboutPage()
addLicense(form.getElement(), "Howard Hinnant's date.h",
"https://github.com/HowardHinnant/date",
":/licenses/howard-hinnant-date.txt");
addLicense(form.getElement(), "{fmt}", "https://fmt.dev",
":/licenses/fmtlib.txt");
}
// Attributions