Skip to content

Commit 7a0a645

Browse files
committed
fixed:log configure not work and improved log configure
1 parent b15dee9 commit 7a0a645

File tree

10 files changed

+97
-93
lines changed

10 files changed

+97
-93
lines changed

XEngine_Release/XEngine_Config/XEngine_CenterConfig.json

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
{
2-
"tszIPAddr":"127.0.0.1",
3-
"bDeamon":0,
4-
"nPort":5000,
5-
"XMax":{
6-
"nMaxClient":10000,
7-
"nMaxQueue":10000,
8-
"nIOThread":2,
9-
"nThread":2
2+
"tszIPAddr": "127.0.0.1",
3+
"bDeamon": 0,
4+
"nPort": 5000,
5+
"XMax": {
6+
"nMaxClient": 10000,
7+
"nMaxQueue": 10000,
8+
"nIOThread": 2,
9+
"nThread": 2
1010
},
11-
"XTime":{
12-
"nTimeCheck":3,
13-
"nTimeOut":5
11+
"XTime": {
12+
"nTimeCheck": 3,
13+
"nTimeOut": 5
1414
},
15-
"XLog":{
16-
"MaxSize":1024000,
17-
"MaxCount":10,
18-
"LogLeave":32
15+
"XLog": {
16+
"LogFile": "./XEngine_Log/XEngine_CenterApp.Log",
17+
"MaxSize": 1024000,
18+
"MaxCount": 10,
19+
"LogLeave": 32,
20+
"LogType": 17
1921
},
20-
"XVer":[
22+
"XVer": [
2123
"V1.4.0.1001 Build20240914",
2224
"V1.2.0.1001 Build20230421",
2325
"V1.1.0.1001 Build20221025",

XEngine_Release/XEngine_Config/XEngine_Http2Config.json

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
{
2-
"tszIPAddr":"127.0.0.1",
3-
"bDeamon":0,
4-
"nPort":5002,
5-
"XMax":{
6-
"nMaxClient":10000,
7-
"nMaxQueue":10000,
8-
"nIOThread":2,
9-
"nThread":2
2+
"tszIPAddr": "127.0.0.1",
3+
"bDeamon": 0,
4+
"nPort": 5002,
5+
"XMax": {
6+
"nMaxClient": 10000,
7+
"nMaxQueue": 10000,
8+
"nIOThread": 2,
9+
"nThread": 2
1010
},
11-
"XTime":{
12-
"nTimeCheck":3,
13-
"nTimeOut":5
11+
"XTime": {
12+
"nTimeCheck": 3,
13+
"nTimeOut": 5
1414
},
15-
"XLog":{
16-
"MaxSize":1024000,
17-
"MaxCount":10,
18-
"LogLeave":32
15+
"XLog": {
16+
"LogFile": "./XEngine_Log/XEngine_Http2App.Log",
17+
"MaxSize": 1024000,
18+
"MaxCount": 10,
19+
"LogLeave": 32,
20+
"LogType": 17
1921
},
20-
"XVer":[
22+
"XVer": [
2123
"V1.3.0.1001 Build20240914",
2224
"V1.2.0.1001 Build20230421",
2325
"V1.1.0.1001 Build20221025",

XEngine_Release/XEngine_Config/XEngine_HttpConfig.json

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
{
2-
"tszIPAddr":"127.0.0.1",
3-
"bDeamon":0,
4-
"nPort":5001,
5-
"XMax":{
6-
"nMaxClient":10000,
7-
"nMaxQueue":10000,
8-
"nIOThread":2,
9-
"nThread":2
2+
"tszIPAddr": "127.0.0.1",
3+
"bDeamon": 0,
4+
"nPort": 5001,
5+
"XMax": {
6+
"nMaxClient": 10000,
7+
"nMaxQueue": 10000,
8+
"nIOThread": 2,
9+
"nThread": 2
1010
},
11-
"XTime":{
12-
"nTimeCheck":3,
13-
"nTimeOut":5
11+
"XTime": {
12+
"nTimeCheck": 3,
13+
"nTimeOut": 5
1414
},
15-
"XLog":{
16-
"MaxSize":1024000,
17-
"MaxCount":10,
18-
"LogLeave":32
15+
"XLog": {
16+
"LogFile": "./XEngine_Log/XEngine_HttpApp.Log",
17+
"MaxSize": 1024000,
18+
"MaxCount": 10,
19+
"LogLeave": 32,
20+
"LogType": 17
1921
},
20-
"XVer":[
22+
"XVer": [
2123
"V1.3.0.1001 Build20240914",
2224
"V1.2.0.1001 Build20230421",
2325
"V1.1.0.1001 Build20221025",

XEngine_Release/XEngine_Config/XEngine_WSConfig.json

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
{
2-
"tszIPAddr":"127.0.0.1",
3-
"bDeamon":0,
4-
"nPort":5003,
5-
"XMax":{
6-
"nMaxClient":10000,
7-
"nMaxQueue":10000,
8-
"nIOThread":2,
9-
"nThread":2
2+
"tszIPAddr": "127.0.0.1",
3+
"bDeamon": 0,
4+
"nPort": 5003,
5+
"XMax": {
6+
"nMaxClient": 10000,
7+
"nMaxQueue": 10000,
8+
"nIOThread": 2,
9+
"nThread": 2
1010
},
11-
"XTime":{
12-
"nTimeCheck":3,
13-
"nTimeOut":5
11+
"XTime": {
12+
"nTimeCheck": 3,
13+
"nTimeOut": 5
1414
},
15-
"XLog":{
16-
"MaxSize":1024000,
17-
"MaxCount":10,
18-
"LogLeave":32
15+
"XLog": {
16+
"LogFile": "./XEngine_Log/XEngine_WebSocketApp.Log",
17+
"MaxSize": 1024000,
18+
"MaxCount": 10,
19+
"LogLeave": 32,
20+
"LogType": 17
1921
},
20-
"XVer":[
22+
"XVer": [
2123
"V1.3.0.1001 Build20240914",
2224
"V1.2.0.1001 Build20230421",
2325
"V1.1.0.1001 Build20221025",

XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ typedef struct tag_XEngine_ServiceConfig
3232
}st_XTime; //次数*时间=超时
3333
struct
3434
{
35+
XCHAR tszLogFile[XPATH_MAX]; //日志路径
3536
int nMaxSize; //最大日志大小
3637
int nMaxCount; //最大日志个数
3738
int nLogLeave; //日志等级
39+
int nLogType; //输出日志类型
3840
}st_XLog;
3941
struct
4042
{

XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE
107107
pSt_ServerConfig->st_XTime.nTimeCheck = st_JsonXTime["nTimeCheck"].asInt();
108108
pSt_ServerConfig->st_XTime.nTimeOut = st_JsonXTime["nTimeOut"].asInt();
109109
//日志配置
110-
if (st_JsonRoot["XLog"].empty() || (3 != st_JsonRoot["XLog"].size()))
110+
if (st_JsonRoot["XLog"].empty() || (5 != st_JsonRoot["XLog"].size()))
111111
{
112112
Config_IsErrorOccur = true;
113113
Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_XLOG;
@@ -117,6 +117,8 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE
117117
pSt_ServerConfig->st_XLog.nMaxSize = st_JsonXLog["MaxSize"].asInt();
118118
pSt_ServerConfig->st_XLog.nMaxCount = st_JsonXLog["MaxCount"].asInt();
119119
pSt_ServerConfig->st_XLog.nLogLeave = st_JsonXLog["LogLeave"].asInt();
120+
pSt_ServerConfig->st_XLog.nLogType = st_JsonXLog["LogType"].asInt();
121+
_tcsxcpy(pSt_ServerConfig->st_XLog.tszLogFile, st_JsonXLog["LogFile"].asCString());
120122
//版本列表
121123
if (st_JsonRoot["XVer"].empty())
122124
{

XEngine_Source/XEngine_ServiceApp/XEngine_CenterApp/XEngine_CenterApp.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,11 @@ int main(int argc, char** argv)
8686
#endif
8787
bIsRun = true;
8888
int nRet = -1;
89-
LPCXSTR lpszLogFile = _X("./XEngine_Log/XEngine_CenterApp.Log");
9089
HELPCOMPONENTS_XLOG_CONFIGURE st_XLogConfig;
9190
THREADPOOL_PARAMENT** ppSt_ListCenterParam;
9291

9392
memset(&st_XLogConfig, '\0', sizeof(HELPCOMPONENTS_XLOG_CONFIGURE));
9493
memset(&st_ServiceConfig, '\0', sizeof(XENGINE_SERVICECONFIG));
95-
96-
st_XLogConfig.XLog_MaxBackupFile = 10;
97-
st_XLogConfig.XLog_MaxSize = 1024000;
98-
_tcsxcpy(st_XLogConfig.tszFileName, lpszLogFile);
9994
//初始化参数
10095
if (!XEngine_Configure_Parament(argc, argv, &st_ServiceConfig))
10196
{
@@ -106,15 +101,18 @@ int main(int argc, char** argv)
106101
{
107102
ServiceApp_Deamon();
108103
}
104+
st_XLogConfig.XLog_MaxBackupFile = st_ServiceConfig.st_XLog.nMaxCount;
105+
st_XLogConfig.XLog_MaxSize = st_ServiceConfig.st_XLog.nMaxSize;
106+
_tcsxcpy(st_XLogConfig.tszFileName, st_ServiceConfig.st_XLog.tszLogFile);
109107
//初始日志
110-
xhLog = HelpComponents_XLog_Init(HELPCOMPONENTS_XLOG_OUTTYPE_STD | HELPCOMPONENTS_XLOG_OUTTYPE_FILE, &st_XLogConfig);
108+
xhLog = HelpComponents_XLog_Init(st_ServiceConfig.st_XLog.nLogType, &st_XLogConfig);
111109
if (NULL == xhLog)
112110
{
113111
printf("启动服务中,启动日志失败,错误:%lX", XLog_GetLastError());
114112
goto XENGINE_SERVICEAPP_EXIT;
115113
}
116114
//设置日志打印级别
117-
HelpComponents_XLog_SetLogPriority(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO);
115+
HelpComponents_XLog_SetLogPriority(xhLog, st_ServiceConfig.st_XLog.nLogLeave);
118116
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化日志系统成功"));
119117

120118
signal(SIGINT, ServiceApp_Stop);

XEngine_Source/XEngine_ServiceApp/XEngine_HTTP2App/XEngine_HTTP2App.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,11 @@ int main(int argc, char** argv)
8787
bIsRun = true;
8888
int nRet = -1;
8989
LPCXSTR lpszHTTPMime = _X("./XEngine_Config/HttpMime.types");
90-
LPCXSTR lpszLogFile = _X("./XEngine_Log/XEngine_Http2App.Log");
9190
HELPCOMPONENTS_XLOG_CONFIGURE st_XLogConfig;
9291
THREADPOOL_PARAMENT** ppSt_ListHTTPParam;
9392

9493
memset(&st_XLogConfig, '\0', sizeof(HELPCOMPONENTS_XLOG_CONFIGURE));
9594
memset(&st_ServiceConfig, '\0', sizeof(XENGINE_SERVICECONFIG));
96-
97-
st_XLogConfig.XLog_MaxBackupFile = 10;
98-
st_XLogConfig.XLog_MaxSize = 1024000;
99-
_tcsxcpy(st_XLogConfig.tszFileName, lpszLogFile);
10095
//初始化参数
10196
if (!XEngine_Configure_Parament(argc, argv, &st_ServiceConfig))
10297
{
@@ -107,15 +102,18 @@ int main(int argc, char** argv)
107102
{
108103
ServiceApp_Deamon();
109104
}
105+
st_XLogConfig.XLog_MaxBackupFile = st_ServiceConfig.st_XLog.nMaxCount;
106+
st_XLogConfig.XLog_MaxSize = st_ServiceConfig.st_XLog.nMaxSize;
107+
_tcsxcpy(st_XLogConfig.tszFileName, st_ServiceConfig.st_XLog.tszLogFile);
110108
//初始日志
111-
xhLog = HelpComponents_XLog_Init(HELPCOMPONENTS_XLOG_OUTTYPE_STD | HELPCOMPONENTS_XLOG_OUTTYPE_FILE, &st_XLogConfig);
109+
xhLog = HelpComponents_XLog_Init(st_ServiceConfig.st_XLog.nLogType, &st_XLogConfig);
112110
if (NULL == xhLog)
113111
{
114112
printf("启动服务中,启动日志失败,错误:%lX", XLog_GetLastError());
115113
goto XENGINE_SERVICEAPP_EXIT;
116114
}
117115
//设置日志打印级别
118-
HelpComponents_XLog_SetLogPriority(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO);
116+
HelpComponents_XLog_SetLogPriority(xhLog, st_ServiceConfig.st_XLog.nLogLeave);
119117
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化日志系统成功"));
120118

121119
signal(SIGINT, ServiceApp_Stop);

XEngine_Source/XEngine_ServiceApp/XEngine_HttpApp/XEngine_HttpApp.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,11 @@ int main(int argc, char** argv)
8888
int nRet = -1;
8989
LPCXSTR lpszHTTPMime = _X("./XEngine_Config/HttpMime.types");
9090
LPCXSTR lpszHTTPCode = _X("./XEngine_Config/HttpCode.types");
91-
LPCXSTR lpszLogFile = _X("./XEngine_Log/XEngine_HttpApp.Log");
9291
HELPCOMPONENTS_XLOG_CONFIGURE st_XLogConfig;
9392
THREADPOOL_PARAMENT** ppSt_ListHTTPParam;
9493

9594
memset(&st_XLogConfig, '\0', sizeof(HELPCOMPONENTS_XLOG_CONFIGURE));
9695
memset(&st_ServiceConfig, '\0', sizeof(XENGINE_SERVICECONFIG));
97-
98-
st_XLogConfig.XLog_MaxBackupFile = 10;
99-
st_XLogConfig.XLog_MaxSize = 1024000;
100-
_tcsxcpy(st_XLogConfig.tszFileName, lpszLogFile);
10196
//初始化参数
10297
if (!XEngine_Configure_Parament(argc, argv, &st_ServiceConfig))
10398
{
@@ -108,15 +103,18 @@ int main(int argc, char** argv)
108103
{
109104
ServiceApp_Deamon();
110105
}
106+
st_XLogConfig.XLog_MaxBackupFile = st_ServiceConfig.st_XLog.nMaxCount;
107+
st_XLogConfig.XLog_MaxSize = st_ServiceConfig.st_XLog.nMaxSize;
108+
_tcsxcpy(st_XLogConfig.tszFileName, st_ServiceConfig.st_XLog.tszLogFile);
111109
//初始日志
112-
xhLog = HelpComponents_XLog_Init(HELPCOMPONENTS_XLOG_OUTTYPE_STD | HELPCOMPONENTS_XLOG_OUTTYPE_FILE, &st_XLogConfig);
110+
xhLog = HelpComponents_XLog_Init(st_ServiceConfig.st_XLog.nLogType, &st_XLogConfig);
113111
if (NULL == xhLog)
114112
{
115113
printf("启动服务中,启动日志失败,错误:%lX", XLog_GetLastError());
116114
goto XENGINE_SERVICEAPP_EXIT;
117115
}
118116
//设置日志打印级别
119-
HelpComponents_XLog_SetLogPriority(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO);
117+
HelpComponents_XLog_SetLogPriority(xhLog, st_ServiceConfig.st_XLog.nLogLeave);
120118
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化日志系统成功"));
121119

122120
signal(SIGINT, ServiceApp_Stop);

XEngine_Source/XEngine_ServiceApp/XEngine_WebSocketApp/XEngine_WebSocketApp.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,11 @@ int main(int argc, char** argv)
8686
#endif
8787
bIsRun = true;
8888
int nRet = -1;
89-
LPCXSTR lpszLogFile = _X("./XEngine_Log/XEngine_WebSocketApp.Log");
9089
HELPCOMPONENTS_XLOG_CONFIGURE st_XLogConfig;
9190
THREADPOOL_PARAMENT** ppSt_ListHTTPParam;
9291

9392
memset(&st_XLogConfig, '\0', sizeof(HELPCOMPONENTS_XLOG_CONFIGURE));
9493
memset(&st_ServiceConfig, '\0', sizeof(XENGINE_SERVICECONFIG));
95-
96-
st_XLogConfig.XLog_MaxBackupFile = 10;
97-
st_XLogConfig.XLog_MaxSize = 1024000;
98-
_tcsxcpy(st_XLogConfig.tszFileName, lpszLogFile);
9994
//初始化参数
10095
if (!XEngine_Configure_Parament(argc, argv, &st_ServiceConfig))
10196
{
@@ -106,15 +101,18 @@ int main(int argc, char** argv)
106101
{
107102
ServiceApp_Deamon();
108103
}
104+
st_XLogConfig.XLog_MaxBackupFile = st_ServiceConfig.st_XLog.nMaxCount;
105+
st_XLogConfig.XLog_MaxSize = st_ServiceConfig.st_XLog.nMaxSize;
106+
_tcsxcpy(st_XLogConfig.tszFileName, st_ServiceConfig.st_XLog.tszLogFile);
109107
//初始日志
110-
xhLog = HelpComponents_XLog_Init(HELPCOMPONENTS_XLOG_OUTTYPE_STD | HELPCOMPONENTS_XLOG_OUTTYPE_FILE, &st_XLogConfig);
108+
xhLog = HelpComponents_XLog_Init(st_ServiceConfig.st_XLog.nLogType, &st_XLogConfig);
111109
if (NULL == xhLog)
112110
{
113111
printf("启动服务中,启动日志失败,错误:%lX", XLog_GetLastError());
114112
goto XENGINE_SERVICEAPP_EXIT;
115113
}
116114
//设置日志打印级别
117-
HelpComponents_XLog_SetLogPriority(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO);
115+
HelpComponents_XLog_SetLogPriority(xhLog, st_ServiceConfig.st_XLog.nLogLeave);
118116
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化日志系统成功"));
119117

120118
signal(SIGINT, ServiceApp_Stop);

0 commit comments

Comments
 (0)