mirror of
https://github.com/tnodir/fort
synced 2024-11-15 05:57:57 +00:00
UI: Use QLoggingCategory, instaed of QDebug
This commit is contained in:
parent
7645754d6e
commit
ee3a206521
@ -208,16 +208,12 @@ bool commandRequiresValidation(Command cmd)
|
||||
|
||||
QDebug operator<<(QDebug debug, Command cmd)
|
||||
{
|
||||
QDebugStateSaver saver(debug);
|
||||
debug.resetFormat().nospace();
|
||||
debug << commandString(cmd);
|
||||
return debug;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, RpcManager rpcManager)
|
||||
{
|
||||
QDebugStateSaver saver(debug);
|
||||
debug.resetFormat().nospace();
|
||||
debug << rpcManagerString(rpcManager);
|
||||
return debug;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "fortmanager.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QThreadPool>
|
||||
@ -38,6 +38,10 @@
|
||||
#include <util/osutil.h>
|
||||
#include <util/startuputil.h>
|
||||
|
||||
namespace {
|
||||
const QLoggingCategory LC("fortManager");
|
||||
}
|
||||
|
||||
FortManager::FortManager(QObject *parent) : QObject(parent), m_initialized(false) { }
|
||||
|
||||
FortManager::~FortManager()
|
||||
@ -60,7 +64,7 @@ bool FortManager::checkRunningInstance(bool isService)
|
||||
return true;
|
||||
|
||||
if (isService) {
|
||||
qWarning() << "Quit due Service is already running!";
|
||||
qCWarning(LC) << "Quit due Service is already running!";
|
||||
} else {
|
||||
QMessageBox::warning(nullptr, QString(), tr("Application is already running!"));
|
||||
}
|
||||
@ -319,7 +323,7 @@ void FortManager::processRestartRequired()
|
||||
|
||||
connect(qApp, &QObject::destroyed, [=] { QProcess::startDetached(appFilePath, args); });
|
||||
|
||||
qDebug() << "Quit due required restart";
|
||||
qCDebug(LC) << "Quit due required restart";
|
||||
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
@ -338,10 +342,10 @@ void FortManager::loadConf()
|
||||
|
||||
IoC<ConfManager>()->load();
|
||||
|
||||
qDebug() << "Started as"
|
||||
<< (settings->isService() ? "Service"
|
||||
: settings->hasService() ? "Service Client"
|
||||
: "Program");
|
||||
qCDebug(LC) << "Started as"
|
||||
<< (settings->isService() ? "Service"
|
||||
: settings->hasService() ? "Service Client"
|
||||
: "Program");
|
||||
}
|
||||
|
||||
bool FortManager::updateDriverConf(bool onlyFlags)
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "logmanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include <conf/confmanager.h>
|
||||
#include <driver/drivercommon.h>
|
||||
@ -18,6 +18,10 @@
|
||||
#include "logentrystattraf.h"
|
||||
#include "logentrytime.h"
|
||||
|
||||
namespace {
|
||||
const QLoggingCategory LC("log.logManager");
|
||||
}
|
||||
|
||||
LogManager::LogManager(QObject *parent) : QObject(parent) { }
|
||||
|
||||
void LogManager::setActive(bool active)
|
||||
@ -149,10 +153,10 @@ void LogManager::readLogEntries(LogBuffer *logBuffer)
|
||||
} break;
|
||||
default:
|
||||
if (logBuffer->offset() < logBuffer->top()) {
|
||||
qCritical() << "Unknown Log entry:" << logType << logBuffer->offset()
|
||||
<< logBuffer->top()
|
||||
<< QByteArray(logBuffer->array().constData() + logBuffer->offset(),
|
||||
logBuffer->top() - logBuffer->offset());
|
||||
qCCritical(LC) << "Unknown Log entry:" << logType << logBuffer->offset()
|
||||
<< logBuffer->top()
|
||||
<< QByteArray(logBuffer->array().constData() + logBuffer->offset(),
|
||||
logBuffer->top() - logBuffer->offset());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "windowmanager.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
#include <QMessageBox>
|
||||
#include <QMouseEvent>
|
||||
#include <QStyle>
|
||||
@ -25,6 +25,8 @@
|
||||
|
||||
namespace {
|
||||
|
||||
const QLoggingCategory LC("manager.windowManager");
|
||||
|
||||
void setupAppStyle()
|
||||
{
|
||||
QStyle *style = QStyleFactory::create("Fusion");
|
||||
@ -366,7 +368,7 @@ void WindowManager::quitByCheckPassword()
|
||||
|
||||
closeAll();
|
||||
|
||||
qDebug() << "Quit due user request";
|
||||
qCDebug(LC) << "Quit due user request";
|
||||
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "zonelistmodel.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include <sqlite/sqlitedb.h>
|
||||
#include <sqlite/sqlitestmt.h>
|
||||
@ -15,6 +15,10 @@
|
||||
#include "zonesourcewrapper.h"
|
||||
#include "zonetypewrapper.h"
|
||||
|
||||
namespace {
|
||||
const QLoggingCategory LC("model.zoneListModel");
|
||||
}
|
||||
|
||||
ZoneListModel::ZoneListModel(QObject *parent) : TableSqlModel(parent) { }
|
||||
|
||||
ConfManager *ZoneListModel::confManager() const
|
||||
@ -227,7 +231,7 @@ void ZoneListModel::setupZoneTypes()
|
||||
QString errorString;
|
||||
const auto zoneTypes = JsonUtil::jsonToVariant(data, errorString).toList();
|
||||
if (!errorString.isEmpty()) {
|
||||
qWarning() << "Zone Types: JSON error:" << errorString;
|
||||
qCWarning(LC) << "Zone Types: JSON error:" << errorString;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -249,7 +253,7 @@ void ZoneListModel::setupZoneSources()
|
||||
QString errorString;
|
||||
const auto zoneSources = JsonUtil::jsonToVariant(data, errorString).toList();
|
||||
if (!errorString.isEmpty()) {
|
||||
qWarning() << "Zone Sources: JSON error:" << errorString;
|
||||
qCWarning(LC) << "Zone Sources: JSON error:" << errorString;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,19 @@
|
||||
#include "windowmanagerfake.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
namespace {
|
||||
const QLoggingCategory LC("rpc.windowManagerFake");
|
||||
}
|
||||
|
||||
WindowManagerFake::WindowManagerFake(QObject *parent) : WindowManager(parent) { }
|
||||
|
||||
void WindowManagerFake::showErrorBox(const QString &text, const QString &title)
|
||||
{
|
||||
qWarning() << title << ":" << text;
|
||||
qCWarning(LC) << title << ":" << text;
|
||||
}
|
||||
|
||||
void WindowManagerFake::showInfoBox(const QString &text, const QString &title)
|
||||
{
|
||||
qInfo() << title << ":" << text;
|
||||
qCInfo(LC) << title << ":" << text;
|
||||
}
|
||||
|
@ -1,14 +1,18 @@
|
||||
#include "taskupdatechecker.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
#include <QVariant>
|
||||
|
||||
#include <fort_version.h>
|
||||
|
||||
#include <util/json/jsonutil.h>
|
||||
#include <util/net/netdownloader.h>
|
||||
#include <util/net/netutil.h>
|
||||
#include <util/json/jsonutil.h>
|
||||
|
||||
namespace {
|
||||
const QLoggingCategory LC("task.taskUpdateChecker");
|
||||
}
|
||||
|
||||
TaskUpdateChecker::TaskUpdateChecker(QObject *parent) : TaskDownloader(parent) { }
|
||||
|
||||
@ -31,7 +35,7 @@ bool TaskUpdateChecker::parseBuffer(const QByteArray &buffer)
|
||||
QString errorString;
|
||||
const auto map = JsonUtil::jsonToVariant(buffer, errorString).toMap();
|
||||
if (!errorString.isEmpty()) {
|
||||
qWarning() << "Update Checker: JSON error:" << errorString;
|
||||
qCWarning(LC) << "Update Checker: JSON error:" << errorString;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "taskzonedownloader.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
#include <QRegularExpression>
|
||||
#include <QUrl>
|
||||
|
||||
@ -11,6 +11,10 @@
|
||||
#include <util/net/netdownloader.h>
|
||||
#include <util/stringutil.h>
|
||||
|
||||
namespace {
|
||||
const QLoggingCategory LC("task.taskZoneDownloader");
|
||||
}
|
||||
|
||||
TaskZoneDownloader::TaskZoneDownloader(QObject *parent) :
|
||||
TaskDownloader(parent), m_zoneEnabled(false), m_sort(false)
|
||||
{
|
||||
@ -97,7 +101,8 @@ bool TaskZoneDownloader::storeAddresses(const StringViewList &list)
|
||||
{
|
||||
Ip4Range ip4Range;
|
||||
if (!ip4Range.fromList(list, emptyNetMask(), sort())) {
|
||||
qWarning() << "TaskZoneDownloader:" << zoneName() << ":" << ip4Range.errorLineAndMessage();
|
||||
qCWarning(LC) << "TaskZoneDownloader:" << zoneName() << ":"
|
||||
<< ip4Range.errorLineAndMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
#include "iconcache.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
#include <QLoggingCategory>
|
||||
#include <QPixmapCache>
|
||||
#include <QThread>
|
||||
|
||||
namespace {
|
||||
|
||||
const QLoggingCategory LC("util.iconCache");
|
||||
|
||||
void checkThread()
|
||||
{
|
||||
#ifdef QT_DEBUG
|
||||
@ -14,7 +16,8 @@ void checkThread()
|
||||
|
||||
const Qt::HANDLE threadId = QThread::currentThreadId();
|
||||
if (g_mainThreadId != threadId) {
|
||||
qWarning() << "QPixmap used by non-main thread:" << threadId << "; main:" << g_mainThreadId;
|
||||
qCWarning(LC) << "QPixmap used by non-main thread:" << threadId
|
||||
<< "; main:" << g_mainThreadId;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
#include "ioccontainer.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include "iocservice.h"
|
||||
|
||||
namespace {
|
||||
const QLoggingCategory LC("util.ioc.iocContainer");
|
||||
}
|
||||
|
||||
int IocContainer::g_tlsIndex = -1;
|
||||
|
||||
IocContainer::IocContainer() = default;
|
||||
@ -18,7 +22,7 @@ void IocContainer::setObject(int typeId, IocObject *obj, quint8 flags)
|
||||
const int newSize = typeId + 1;
|
||||
if (newSize > m_size) {
|
||||
if (Q_UNLIKELY(newSize >= IOC_MAX_SIZE)) {
|
||||
qCritical() << "IoC Container size error";
|
||||
qCCritical(LC) << "IoC Container size error";
|
||||
Q_UNREACHABLE();
|
||||
abort();
|
||||
}
|
||||
@ -98,7 +102,7 @@ void IocContainer::createTlsIndex()
|
||||
if (g_tlsIndex == -1) {
|
||||
g_tlsIndex = TlsAlloc();
|
||||
if (g_tlsIndex == -1) {
|
||||
qWarning() << "TlsAlloc error";
|
||||
qCCritical(LC) << "TlsAlloc error";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,23 @@
|
||||
#include "netdownloader.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#define DOWNLOAD_TIMEOUT (30 * 1000) // 30 milliseconds timeout
|
||||
#define DOWNLOAD_MAXSIZE (8 * 1024 * 1024)
|
||||
|
||||
namespace {
|
||||
const QLoggingCategory LC("util.net.netDownloader");
|
||||
}
|
||||
|
||||
NetDownloader::NetDownloader(QObject *parent) :
|
||||
QObject(parent), m_started(false), m_aborted(false), m_manager(new QNetworkAccessManager(this))
|
||||
{
|
||||
m_downloadTimer.setInterval(DOWNLOAD_TIMEOUT);
|
||||
|
||||
connect(&m_downloadTimer, &QTimer::timeout, this, [&] {
|
||||
qDebug() << "NetDownloader: Error: Download timed out";
|
||||
qCDebug(LC) << "NetDownloader: Error: Download timed out";
|
||||
|
||||
finish();
|
||||
});
|
||||
@ -28,7 +32,7 @@ QByteArray NetDownloader::takeBuffer()
|
||||
|
||||
void NetDownloader::start()
|
||||
{
|
||||
qDebug() << "NetDownloader: Start:" << url() << data();
|
||||
qCDebug(LC) << "NetDownloader: Start:" << url() << data();
|
||||
|
||||
m_started = true;
|
||||
m_aborted = false;
|
||||
@ -55,7 +59,7 @@ void NetDownloader::start()
|
||||
|
||||
m_buffer.append(data);
|
||||
if (m_buffer.size() >= DOWNLOAD_MAXSIZE) {
|
||||
qWarning() << "NetDownloader: Error: Too big file";
|
||||
qCWarning(LC) << "NetDownloader: Error: Too big file";
|
||||
finish();
|
||||
}
|
||||
});
|
||||
@ -68,7 +72,7 @@ void NetDownloader::start()
|
||||
if (m_aborted)
|
||||
return;
|
||||
|
||||
qWarning() << "NetDownloader: Error:" << error << m_reply->errorString();
|
||||
qCWarning(LC) << "NetDownloader: Error:" << error << m_reply->errorString();
|
||||
|
||||
finish();
|
||||
});
|
||||
@ -77,7 +81,7 @@ void NetDownloader::start()
|
||||
return;
|
||||
|
||||
for (const QSslError &error : errors) {
|
||||
qWarning() << "NetDownloader: SSL Error:" << error.errorString();
|
||||
qCWarning(LC) << "NetDownloader: SSL Error:" << error.errorString();
|
||||
}
|
||||
|
||||
finish();
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "osutil.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QLoggingCategory>
|
||||
#include <QProcess>
|
||||
#include <QUrl>
|
||||
|
||||
@ -16,9 +16,11 @@
|
||||
|
||||
namespace {
|
||||
|
||||
const QLoggingCategory LC("util.osUtil");
|
||||
|
||||
BOOL WINAPI consoleCtrlHandler(DWORD /*ctrlType*/)
|
||||
{
|
||||
qDebug() << "Quit due console control";
|
||||
qCDebug(LC) << "Quit due console control";
|
||||
|
||||
QCoreApplication::quit();
|
||||
Sleep(100); // Let the process exit gracefully
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "serviceworker.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <qt_windows.h>
|
||||
@ -10,6 +10,8 @@
|
||||
|
||||
namespace {
|
||||
|
||||
const QLoggingCategory LC("util.serviceWorker");
|
||||
|
||||
/* Service global structure */
|
||||
static struct
|
||||
{
|
||||
@ -28,7 +30,7 @@ void WINAPI serviceCtrlHandler(DWORD code)
|
||||
switch (code) {
|
||||
case SERVICE_CONTROL_STOP:
|
||||
case SERVICE_CONTROL_SHUTDOWN:
|
||||
qDebug() << "Quit due service control";
|
||||
qCDebug(LC) << "Quit due service control";
|
||||
|
||||
qApp->connect(qApp, &QObject::destroyed, [] { reportServiceStatus(SERVICE_STOPPED); });
|
||||
QCoreApplication::quit(); // it's threadsafe
|
||||
|
Loading…
Reference in New Issue
Block a user