Explorar o código

打印创建与关闭文件的日志,查看是否成对匹配

scbc.sat2 %!s(int64=5) %!d(string=hai) anos
pai
achega
1057ebb046
Modificáronse 1 ficheiros con 3 adicións e 16 borrados
  1. 3 16
      LogModule/LogModule/Global.cpp

+ 3 - 16
LogModule/LogModule/Global.cpp

@@ -149,32 +149,18 @@ namespace Global
 			_tcscpy_s(szLastLog, g_szLogPath);
 			if ( gp_log_fp != NULL )
 			{	
+				WriteTextLog(_T("关闭文件:%s"), g_szLogPath);
 				fclose(gp_log_fp);
 				gp_log_fp = NULL;
 			}
-#if 0
-			int fd = 0;
-			if (_tsopen_s(&fd, g_szLogPath, _O_CREAT | _O_WRONLY | _O_APPEND, _SH_DENYRW, _S_IREAD | _S_IWRITE))
-			{
-				WriteTextLog(_T("创建文件描述符失败:%s,%d,%d"), g_szLogPath, nErr, GetLastError());
-				return;
-			}
 
-			// 创建并打开文件;
-			gp_log_fp = _tfdopen(fd, _T("w+"));
-			if (gp_log_fp == NULL )
-			{
-				WriteTextLog(_T("创建文件失败:%s,%d,%d"), g_szLogPath, nErr, GetLastError());
-				return;
-			}
-#else
 			nErr = _tfopen_s(&gp_log_fp, g_szLogPath, "w+");
 			if ( gp_log_fp == NULL )
 			{
 				WriteTextLog(_T("创建文件失败:%s,%d,%d"), g_szLogPath, nErr, GetLastError());
 				return;
 			}
-#endif
+			WriteTextLog(_T("创建文件成功:%s"), g_szLogPath);
 		}
 
 		if (gp_log_fp == NULL )
@@ -200,6 +186,7 @@ namespace Global
 		AutoThreadSection aSection(&g_critSection);
 		if ( gp_log_fp )
 		{
+			WriteTextLog(_T("关闭文件:%s"), g_szLogPath);
 			fclose(gp_log_fp);
 			gp_log_fp = NULL;
 		}