|
@@ -1,15 +1,27 @@
|
|
|
#include "stdafx.h"
|
|
|
#include "mod_alarm.h"
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
-#else
|
|
|
+#ifdef RVC_OS_LINUX
|
|
|
#include <sys/timeb.h>
|
|
|
+#include "SpUtility.h"
|
|
|
#endif
|
|
|
|
|
|
+
|
|
|
void CAlarmEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
|
|
|
const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
|
|
|
const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage)
|
|
|
{
|
|
|
//Dbg("receive log,pszEntityName=%s,eLogType=%d,pszMessage=%s",pszEntityName,(int)eLogType,pszMessage);
|
|
|
+ CSimpleStringA strMessage(true);
|
|
|
+ if (!(pszMessage == NULL || strlen(pszMessage) == 0))
|
|
|
+ strMessage = pszMessage;
|
|
|
+
|
|
|
+#if defined(RVC_OS_LINUX)
|
|
|
+ if (!strMessage.IsNullOrEmpty()) {
|
|
|
+ std::string tmpStr = SP::Utility::UTF8ToGBK(pszMessage);
|
|
|
+ strMessage = tmpStr.c_str();
|
|
|
+ }
|
|
|
+#endif //RVC_OS_LINUX
|
|
|
+
|
|
|
alarm_t*Alarm = new alarm_t();
|
|
|
char cEntityName[32]={0};
|
|
|
strcpy(cEntityName,pszEntityName);
|
|
@@ -32,7 +44,7 @@ void CAlarmEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,con
|
|
|
_itoa((int)eLogType,&Alarm->Level,16);//把level替换成logtype,
|
|
|
|
|
|
//char cDescription[512]={0};
|
|
|
- //strncpy(cDescription,pszMessage,512-1);
|
|
|
+ //strncpy(cDescription,strMessage.GetData(),512-1);
|
|
|
//Alarm->Description = _strdup(cDescription);
|
|
|
|
|
|
char cDescription[512] = { 0 };
|
|
@@ -49,7 +61,7 @@ void CAlarmEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,con
|
|
|
sprintf(clogTime, "%04d-%02d-%02d %02d:%02d:%02d.%03d", nowTm.tm_year + 1900, nowTm.tm_mon + 1, nowTm.tm_mday, nowTm.tm_hour, nowTm.tm_min, nowTm.tm_sec, stime.millitm);
|
|
|
#endif
|
|
|
strncpy(cDescription, clogTime, 32);
|
|
|
- strncat(cDescription, pszMessage, 512 - 32 - 1);
|
|
|
+ strncat(cDescription, strMessage.GetData(), 512 - 32 - 1);
|
|
|
Alarm->Description = _strdup(cDescription);
|
|
|
|
|
|
|