Forráskód Böngészése

#IQRV #comment [BugFix][GUIConsole] 延长判断db文件大小的时间并且修改告警等级,10MB以上才告警

gifur 3 éve
szülő
commit
b8ff197537

+ 1 - 1
Module/mod_guiconsole/mod_GuiConsole.h

@@ -9,7 +9,7 @@
 using namespace GUIConsole;
 
 #define ENT_TIMERID_CHECK_LOGDB_SIZE 1
-#define ENT_TIMERINTERVAL_CHECK_LOGDB_SIZE 60 * 1000
+#define ENT_TIMERINTERVAL_CHECK_LOGDB_SIZE 300 * 1000
 
 // 本地控制台 GUIConsole	0x508
 class CGUIConsoleEntity : public CEntityBase, public ILogListener, public ITimerListener

+ 9 - 6
Module/mod_guiconsole/mod_guiconsole.cpp

@@ -622,24 +622,27 @@ void CGUIConsoleEntity::InitializeBeidou()
 void CGUIConsoleEntity::OnTimeout(DWORD dwTimerID)
 {
 	static long oldFileSize = -1;
+	const long maxFileSize = 10000000; //10MB
     const char* defaultDBStoragePath = "/opt/rvc/terminaldbstorage/RVC.LogSdk/RvcLogSdk.db";
 
 	if (dwTimerID == ENT_TIMERID_CHECK_LOGDB_SIZE) {
 		if (ExistsFileA(defaultDBStoragePath)) {
 			struct stat statbuf;
-            if (stat(defaultDBStoragePath, &statbuf)) {
+            if (stat(defaultDBStoragePath, &statbuf) < 0) {
 				int err = errno;
-				LogWarn(Severity_Middle, Error_Resource, EVENT_MOD_GUICONSOLE_UNIONNETLOG_LOCAL_STORAGE_SIZE,
+				LogWarn(Severity_Low, Error_Resource, EVENT_MOD_GUICONSOLE_UNIONNETLOG_LOCAL_STORAGE_SIZE,
 						CSimpleStringA::Format("failed to stat %s: %s", defaultDBStoragePath, strerror(err)));
 			} else {
 				if (oldFileSize != statbuf.st_size) {
-                    LogWarn(Severity_Middle, Error_Resource, EVENT_MOD_GUICONSOLE_UNIONNETLOG_LOCAL_STORAGE_SIZE,
-                            CSimpleStringA::Format("db file changed from: %d to %ld", oldFileSize, statbuf.st_size));
-					oldFileSize = statbuf.st_size;
+					if (statbuf.st_size >= maxFileSize) {
+                        LogWarn(Severity_Low, Error_Resource, EVENT_MOD_GUICONSOLE_UNIONNETLOG_LOCAL_STORAGE_SIZE,
+                                CSimpleStringA::Format("db file changed from: %d to %ld", oldFileSize, statbuf.st_size));
+					}
+                    oldFileSize = statbuf.st_size;
 				}
 			}
 		} else {
-			LogWarn(Severity_Middle, Error_Resource, EVENT_MOD_GUICONSOLE_UNIONNETLOG_LOCAL_STORAGE_SIZE,
+			LogWarn(Severity_Low, Error_Resource, EVENT_MOD_GUICONSOLE_UNIONNETLOG_LOCAL_STORAGE_SIZE,
 					CSimpleStringA::Format("%s does not exist!", defaultDBStoragePath));
 		}
 	}