chore: update files of project

This commit is contained in:
Qsaker 2024-01-29 11:13:05 +08:00
parent ef2965ae6a
commit 1e1f75274c
3 changed files with 14 additions and 16 deletions

View File

@ -57,13 +57,13 @@ static void sakShutdownGoogleLogging()
#endif
#ifdef SAK_USING_GLOG
static void qtLogToGoogleLog(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toUtf8();
const char *file = context.file ? context.file : "";
const int line = context.line;
#ifdef SAK_USING_GLOG
switch (type) {
case QtWarningMsg:
google::LogMessage(file, line, google::GLOG_WARNING).stream() << localMsg.data();
@ -78,12 +78,8 @@ static void qtLogToGoogleLog(QtMsgType type, const QMessageLogContext &context,
google::LogMessage(file, line, google::GLOG_INFO).stream() << localMsg.data();
break;
}
#else
Q_UNUSED(localMsg)
Q_UNUSED(file)
Q_UNUSED(line)
#endif
}
#endif
static void sakInitApp(const QString &appName)
{
@ -154,8 +150,12 @@ static void sakInitAppStyle()
static void sakDoSomethingBeforeAppCreated(char *argv[], const QString &appName)
{
sakInitApp(appName);
#ifdef SAK_USING_GLOG
sakInitGoogleLogging(argv[0]);
sakInstallMessageHandler();
#else
Q_UNUSED(argv)
#endif
sakTryToClearSettings();
#if 0
sakInitLanguage();
@ -166,5 +166,7 @@ static void sakDoSomethingBeforeAppCreated(char *argv[], const QString &appName)
static void sakDoSomethingAfterAppExited()
{
#ifdef SAK_USING_GLOG
sakShutdownGoogleLogging();
#endif
}

View File

@ -1,5 +1,5 @@
/***************************************************************************************************
* Copyright 2023 Qsaker(qsaker@foxmail.com). All rights reserved.
* Copyright 2023-2024 Qsaker(qsaker@foxmail.com). All rights reserved.
*
* The file is encoded using "utf8 with bom", it is a part of QtSwissArmyKnife project.
*
@ -117,9 +117,7 @@ void SAKWebSocketServerTool::uninitialize()
mWebSocketServer = nullptr;
}
void SAKWebSocketServerTool::writeBytesInner(QWebSocket *client,
const QByteArray &bytes,
const QVariant &context)
void SAKWebSocketServerTool::writeBytesInner(QWebSocket *client, const QByteArray &bytes)
{
qint64 ret = -1;
QString hex;
@ -132,12 +130,12 @@ void SAKWebSocketServerTool::writeBytesInner(QWebSocket *client,
}
if (ret == -1) {
//outputMessage(QtWarningMsg, client->errorString());
qWarning() << client->errorString();
} else {
QString ip = client->peerAddress().toString();
quint16 port = client->peerPort();
QString ipport = QString("%1:%2").arg(ip, QString::number(port));
//outputMessage(QtInfoMsg, QString("%1->%2:%3").arg(this->mBindingIpPort, ipport, hex));
qInfo() << QString("%1->%2:%3").arg(this->m_bindingIpPort, ipport, hex);
emit bytesWritten(bytes, ipport);
}
}

View File

@ -1,5 +1,5 @@
/***************************************************************************************************
* Copyright 2023 Qsaker(qsaker@foxmail.com). All rights reserved.
* Copyright 2023-2024 Qsaker(qsaker@foxmail.com). All rights reserved.
*
* The file is encoded using "utf8 with bom", it is a part of QtSwissArmyKnife project.
*
@ -24,9 +24,7 @@ protected:
virtual void uninitialize() final;
private:
void writeBytesInner(QWebSocket *client,
const QByteArray &bytes,
const QVariant &context = QJsonObject());
void writeBytesInner(QWebSocket *client, const QByteArray &bytes);
private:
QWebSocketServer *mWebSocketServer{nullptr};