Commit 0ba5bc93 by NitefullWind

1. 可配置日志相关参数。

parent 35113112
...@@ -76,7 +76,9 @@ public: ...@@ -76,7 +76,9 @@ public:
DataProcess::GetJsonKeyArray(list, json); DataProcess::GetJsonKeyArray(list, json);
DataProcess::SortString(list); DataProcess::SortString(list);
QLOG_INFO() << "list: " << list;
DataProcess::GetValueFromJson(list, json, values); DataProcess::GetValueFromJson(list, json, values);
QLOG_INFO() << "values: " << values;
QByteArray array = values.toUtf8(); QByteArray array = values.toUtf8();
......
...@@ -107,10 +107,10 @@ void RollBack::run() ...@@ -107,10 +107,10 @@ void RollBack::run()
while(!isInterruptionRequested()) while(!isInterruptionRequested())
{ {
int timeout = QSettings(path + "\\" + USERCONFIG_NAME, QSettings::IniFormat).value(VALUE_TIMEOUT).toInt(); // int timeout = setting.GetValue(VALUE_TIMEOUT, 30).toInt();
if(timeout == 0) // if(timeout == 0)
timeout = 30; // timeout = 30;
do do
{ {
...@@ -128,11 +128,12 @@ void RollBack::run() ...@@ -128,11 +128,12 @@ void RollBack::run()
}while(0); }while(0);
QEventLoop loop; // QEventLoop loop;
QTimer timer; // QTimer timer;
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); // connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
timer.start(timeout*1000); // timer.start(timeout*1000);
loop.exec(); // loop.exec();
this->sleep(1);
} }
} }
...@@ -435,8 +435,6 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata, ...@@ -435,8 +435,6 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
int result = skbSend(in, guid, out, errMsg, mode.data(), operation.data()); int result = skbSend(in, guid, out, errMsg, mode.data(), operation.data());
#endif //! End def MOCK #endif //! End def MOCK
QLOG_DEBUG() << "StarbucksAPI return to GBK: " << QString::fromLocal8Bit(out);
QString outXMlString = QString::fromLocal8Bit(out); QString outXMlString = QString::fromLocal8Bit(out);
QLOG_INFO() << "OLTP return: " << result << " data: " << outXMlString; QLOG_INFO() << "OLTP return: " << result << " data: " << outXMlString;
......
...@@ -106,6 +106,11 @@ ...@@ -106,6 +106,11 @@
#define CONFIG_PRINT_ENDDAY_NAME "PRINT/EDNDAYNAME" #define CONFIG_PRINT_ENDDAY_NAME "PRINT/EDNDAYNAME"
#define CONFIG_PRINT_SHIFT_NAME "PRINT/SHIFTNAME" #define CONFIG_PRINT_SHIFT_NAME "PRINT/SHIFTNAME"
#define CONFIG_PRINT_AGAIN_NAME "PRINT/AGAINNAME" #define CONFIG_PRINT_AGAIN_NAME "PRINT/AGAINNAME"
#define CONFIG_LOG_PATH "LOG/PATH"
#define CONFIG_LOG_NAME "LOG/NAME"
#define CONFIG_LOG_LEVEL "LOG/LEVEL"
#define CONFIG_LOG_SIZE "LOG/SIZE"
#define CONFIG_LOG_COUNT "LOG/COUNT"
#endif // GLOBAL #endif // GLOBAL
...@@ -81,7 +81,7 @@ BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpvReserved*/ ...@@ -81,7 +81,7 @@ BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpvReserved*/
qputenv("PATH", val); qputenv("PATH", val);
FMPSettings setting; FMPSettings setting;
QString configPath = setting.GetValue(CONFIG_ALL_PATH, "C:\\Freemud\\").toString(); QString configPath = setting.GetValue(CONFIG_ALL_PATH, path).toString();
QApplication::addLibraryPath(configPath); QApplication::addLibraryPath(configPath);
qDebug() << "Library paths: " << QApplication::libraryPaths() << configPath; qDebug() << "Library paths: " << QApplication::libraryPaths() << configPath;
...@@ -101,17 +101,29 @@ extern "C" __declspec(dllexport) void Start(const char *indata, char *outdata) ...@@ -101,17 +101,29 @@ extern "C" __declspec(dllexport) void Start(const char *indata, char *outdata)
char path[MAX_PATH] = {0}; char path[MAX_PATH] = {0};
ToolS::GetProcPath(path); ToolS::GetProcPath(path);
QString logDir = QString("%1/log").arg(QString(path)); FMPSettings setting;
QDir().mkdir(logDir); QString logPath = setting.GetValue(CONFIG_LOG_PATH, QString(path)+"/log").toString();
QString logName = setting.GetValue(CONFIG_LOG_NAME, "sbuxpay.txt").toString();
QsLogging::Level logLevel = (QsLogging::Level)setting.GetValue(CONFIG_LOG_LEVEL, 0).toInt();
if(logLevel < QsLogging::TraceLevel || logLevel > QsLogging::OffLevel) {
logLevel = QsLogging::TraceLevel;
}
int logSize = setting.GetValue(CONFIG_LOG_SIZE, 1).toInt();
int logCount = setting.GetValue(CONFIG_LOG_COUNT, 5).toInt();
QDir logDir(logPath);
if(!logDir.exists()) {
logDir.mkpath(logDir.absolutePath());
}
QString logFilePath = logDir.absolutePath()+'/'+logName;
QsLogging::Logger& logger = QsLogging::Logger::instance(); QsLogging::Logger& logger = QsLogging::Logger::instance();
logger.setLoggingLevel(QsLogging::TraceLevel); logger.setLoggingLevel(logLevel);
QString str = QString(path) + "\\log\\sbuxpay.txt";
/* 配置输出定向器 */ /* 配置输出定向器 */
QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination( QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(
str, logFilePath,
QsLogging::EnableLogRotation, QsLogging::MaxSizeBytes(1024*1024), QsLogging::EnableLogRotation, QsLogging::MaxSizeBytes(1024*1024*logSize),
QsLogging::MaxOldLogCount(5))); QsLogging::MaxOldLogCount(logCount)));
logger.addDestination(fileDestination); logger.addDestination(fileDestination);
QsLogging::DestinationPtr consleDest(QsLogging::DestinationFactory::MakeDebugOutputDestination()); QsLogging::DestinationPtr consleDest(QsLogging::DestinationFactory::MakeDebugOutputDestination());
......
...@@ -364,7 +364,7 @@ private: ...@@ -364,7 +364,7 @@ private:
QString printFileName = setting.GetValue(configKey, PRINT_FILE_NAME).toString(); QString printFileName = setting.GetValue(configKey, PRINT_FILE_NAME).toString();
QString filePath = path; QString filePath = dir.absolutePath();
if(!filePath.endsWith('/') && !filePath.endsWith('\\')) { if(!filePath.endsWith('/') && !filePath.endsWith('\\')) {
filePath.append('\\'); filePath.append('\\');
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_REVISION 0 #define VER_REVISION 0
#define VER_BUILD 37 #define VER_BUILD 38
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #define _STR(S) #S
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "jsonfactory.h" #include "jsonfactory.h"
#include "fmnetwork.h" #include "fmnetwork.h"
#include "tools.h" #include "tools.h"
#include "cretopt.h"
#include <QDebug> #include <QDebug>
// add necessary includes here // add necessary includes here
...@@ -26,6 +27,8 @@ private slots: ...@@ -26,6 +27,8 @@ private slots:
void test_CreateOLTPXML_data(); void test_CreateOLTPXML_data();
void test_CreateOLTPXML(); void test_CreateOLTPXML();
void test_GetSign();
}; };
TestSimphony::TestSimphony() TestSimphony::TestSimphony()
...@@ -167,6 +170,20 @@ void TestSimphony::test_InitPOSReqJsonObj() ...@@ -167,6 +170,20 @@ void TestSimphony::test_InitPOSReqJsonObj()
QCOMPARE(resultJson["statusCode"].toInt(), 100); QCOMPARE(resultJson["statusCode"].toInt(), 100);
} }
void TestSimphony::test_GetSign()
{
QByteArray rollbackString = "{\"businessDate\":\"20170907\",\"code\":\"282100361166771154\",\"mac\":\"F8-0F-41-82-C4-1F\",\"operatorId\":\"16151427\",\"partnerId\":1446,\"partnerOrderId\":\"1446130116446320170907164514\",\"promotionTag\":\"\",\"reqType\":72,\"sign\":\"WgxSX+sf5V0u6Zw4Vki/lswwAou+EX5aLL8g2WYVcYMEmkJsBEUNZsT/RHgVUZT4GiWbKSOixLf80qcES1ovZO4/nzEM7YoDBCeCBFZzhRmAWyIDa33lh23mm9JCgTF9T44kkxGmJtAnPyxUKPatZCSF0gfyjMjyqosInaxIxNA=\",\"stationId\":\"4463\",\"storeId\":\"130116\",\"transAmount\":100800,\"transId\":431,\"undiscountAmount\":0,\"ver\":1}";
QJsonDocument jsonDocument = QJsonDocument::fromJson(rollbackString);
QJsonObject json = jsonDocument.object();
qDebug() << json;
json[JSON_KEY_REQTYPE] = 3;
json[JSON_KEY_VER] = DEFAULT_JSON_VER_VALUE;
QCOMPARE(CretOperate::GetSign(json), true);
}
QTEST_MAIN(TestSimphony) QTEST_MAIN(TestSimphony)
#include "tst_testsimphony.moc" #include "tst_testsimphony.moc"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment