Browse Source

#IQRV #comment [Mixed] GPIO和WatchDog 埋点日志改造

gifur 3 years ago
parent
commit
8ca8ad531e

+ 1 - 1
Module/mod_IDCertificate/IDCertFSM.cpp

@@ -1239,7 +1239,7 @@ int CIDCertFSM::ReadHZCard(SpReqAnsContext<IDCert_ReadEx_Req, IDCert_ReadEx_Ans>
 	//	device_close(itc);
 	//}
 	//else
-	//	Dbg("device_open failed result:%x", itc);
+	//	DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("device_open failed result:%x", itc);
 	//eErr = CreateDevComponent((DeviceBaseClass *&)m_hDevHelper);
 	//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("after read card,CreateDevComponent result:%d", eErr);
 	//eErr = m_hDevHelper->DevOpen(0);

+ 40 - 41
Module/mod_gpio/mod_gpio.cpp

@@ -72,7 +72,7 @@ static const char* GetDriverPortString(int pin)
     //case 41: return "";
     //case 42: return "";
     default:
-        Dbg("Unkown pin sequence: %d", pin);
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Unkown pin sequence: %d", pin);
         return "";
         break;
     }
@@ -105,7 +105,7 @@ static const char* GetLightSeqString(int seq)
     LIGHT_STRING_CONVERT(PRINTER_SEAL)
     LIGHT_STRING_CONVERT(FINGERPRINT)
     default:
-        Dbg("Unkonwn LightSeq: %d", seq);
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Unkonwn LightSeq: %d", seq);
         return "UnConver One";
         break;
     }
@@ -116,9 +116,9 @@ static const char* GetLightSeqString(int seq)
 void CGpioServiceSession::Handle_Set(SpOnewayCallContext<GpioService_Set_Info>::Pointer ctx)
 {
     GpioService_Set_Info req = ctx->Info;
-    Dbg("devseq=%d", req.devseq);
-    Dbg("mode=%d", req.mode);
-    Dbg("close=%d", req.close);
+    DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("devseq=%d", req.devseq);
+    DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("mode=%d", req.mode);
+    DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("close=%d", req.close);
     m_pEntity->Set(req);
 }
 void CGpioServiceSession::Handle_GetStatus(SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
@@ -212,7 +212,7 @@ ErrorCodeEnum CGpioEntity::Initial()
     CSimpleStringA dllName;
     eErrDev = ExtractVendorLibFullPath(dllName);
     if (eErrDev != Error_Succeed) {
-        Dbg("load vendor dll or so(%s)(%s) failed.", dllName.GetData(), SpStrError(eErrDev));
+        DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("load vendor dll or so(%s)(%s) failed.", dllName.GetData(), SpStrError(eErrDev));
         return Error_DevLoadFileFailed;
     }
 
@@ -221,7 +221,7 @@ ErrorCodeEnum CGpioEntity::Initial()
     CSmartPointer<IConfigInfo> spConfig;
     eErrDev = spEntityFunction->OpenConfig(Config_Root, spConfig);
     if (eErrDev != Error_Succeed) {
-        Dbg("open cfg file failed!");
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("open cfg file failed!");
         return eErrDev;
     }
 
@@ -231,7 +231,7 @@ ErrorCodeEnum CGpioEntity::Initial()
     spConfig->ReadConfigValue("Device.Gpio", "Version", devVer);
     spConfig->ReadConfigValue("Device.Gpio", "Batch", devBatch);
 #if defined(RVC_OS_WIN)
-    Dbg("[%s],[%s],[%s]", devVendor.GetData(), devVer.GetData(), devBatch.GetData());
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("[%s],[%s],[%s]", devVendor.GetData(), devVer.GetData(), devBatch.GetData());
     if (!_stricmp(devVendor, "Hyosung") || !_stricmp(devVendor, "Keba") || !_stricmp(devVendor, "Kxd")) {
         if (devVer == "1" && devBatch == "1") {
             m_bNewVersion = FALSE;
@@ -247,13 +247,13 @@ ErrorCodeEnum CGpioEntity::Initial()
 
     eErrDev = m_hDevHelper.LoadUp(dllName);
     if (eErrDev != Error_Succeed) {
-        Dbg("load up %s failed: %s", dllName.GetData(), SpStrError(eErrDev));
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("load up %s failed: %s", dllName.GetData(), SpStrError(eErrDev));
         return Error_DevLoadFileFailed;
     }
 	m_adapterInfo.adapterFileName = dllName;
     int initTries = 0;
     do {
-        Dbg("to open device.");
+        DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to open device.");
         int portNum, inOutDir, port, baudRate;
         err = spConfig->ReadConfigValueInt("Device.Gpio", "PortNum", portNum);
         if (err == Error_Succeed)
@@ -268,7 +268,7 @@ ErrorCodeEnum CGpioEntity::Initial()
         spConfig->ReadConfigValueInt("Device.Gpio", "Port", port);
         spConfig->ReadConfigValueInt("Device.Gpio", "BaudRate", baudRate);
 
-        Dbg("read cfg suc, port(%d), baudrate(%d).", port, baudRate);
+        DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("read cfg suc, port(%d), baudrate(%d).", port, baudRate);
 		m_port = CSimpleStringA::Format("%d", port);
 		m_Baudrate = CSimpleStringA::Format("%d", baudRate);
 		m_portNum = CSimpleStringA::Format("%d", portNum);
@@ -285,7 +285,7 @@ ErrorCodeEnum CGpioEntity::Initial()
             initParam.dir[1] = true;
             initParam.dir[2] = false;
             initParam.dir[3] = true;
-            Dbg("New available 4 port num");
+            DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("New available 4 port num");
         }
 		CSimpleStringA errMsg("");
         initParam.dwPort = port;
@@ -298,7 +298,7 @@ ErrorCodeEnum CGpioEntity::Initial()
 			err = m_hDevHelper->GetDevCategory(m_devCatInfo);
 			if (err == Error_Succeed)
 			{
-				Dbg("szVendor:%s, szType:%s, szModel:%s", m_devCatInfo.szVendor, m_devCatInfo.szType, m_devCatInfo.szModel);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("szVendor:%s, szType:%s, szModel:%s", m_devCatInfo.szVendor, m_devCatInfo.szType, m_devCatInfo.szModel);
 				m_adapterInfo.devCatInfo = m_devCatInfo;
 			}
 			else
@@ -329,12 +329,12 @@ ErrorCodeEnum CGpioEntity::Initial()
     }
 
     err = m_hDevHelper->WritePort(0, 0x00);
-    Dbg("write ports(0) returned: %d)", err);
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write ports(0) returned: %d)", err);
     err = m_hDevHelper->WritePort(1, 0x00);
-    Dbg("write ports(1) returned: %d", err);
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write ports(1) returned: %d", err);
     if (m_bNewVersion) {
         err = m_hDevHelper->WritePort(3, 0x00);
-        Dbg("write ports(3) returned: %d", err);
+        DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write ports(3) returned: %d", err);
     }
 
     //oilyang@20170214 
@@ -353,7 +353,7 @@ ErrorCodeEnum CGpioEntity::Initial()
     }
     m_moveDisappearTimes = m_moveHoldTimes;
     m_eMachineType = SP::Module::Comm::GetTerminalMachineInfo(this).type;
-    Dbg("machine type: %s", SP::Module::Comm::Type2Str(m_eMachineType));
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("machine type: %s", SP::Module::Comm::Type2Str(m_eMachineType));
 
 	if (m_FirstStart) {
 		m_FirstStart = FALSE;
@@ -366,7 +366,7 @@ void CGpioEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nLogID, con
                         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, const linkContext& pLinkInfo)
 {
-    Dbg("usercode [%x]", dwUserCode);
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("usercode [%x]", dwUserCode);
     GpioService_Set_Info Req;
     Req.close = 0;
     switch (dwUserCode) {
@@ -524,10 +524,10 @@ void CGpioEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nLogID, con
         Req.close = 1;
         break;
     default:
-        Dbg("unkown event: 0x%X", dwUserCode);
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("unkown event: 0x%X", dwUserCode);
         return;
     }
-    Dbg("devseq[%d],mode[%d]close[%d]", Req.devseq, Req.mode, Req.close);
+    DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("devseq[%d],mode[%d]close[%d]", Req.devseq, Req.mode, Req.close);
     Set(Req);
 }
 
@@ -546,7 +546,7 @@ void CGpioEntity::WritePin(DWORD dwPinSeq, bool bHighLevel)
         else
             CLEARBIT(m_btOutputStatus[3], dwPinSeq - 24);
         result = m_hDevHelper->WritePort(3, m_btOutputStatus[3]);
-        Dbg("after write port3, %d returned %s", m_btOutputStatus[3], SpStrError(result));
+        DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("after write port3, %d returned %s", m_btOutputStatus[3], SpStrError(result));
         return;
     }
 
@@ -556,7 +556,7 @@ void CGpioEntity::WritePin(DWORD dwPinSeq, bool bHighLevel)
         else
             CLEARBIT(m_btOutputStatus[0], dwPinSeq);
         result = m_hDevHelper->WritePort(0, m_btOutputStatus[0]);
-        Dbg("after write port0,%d returned %s", m_btOutputStatus[0], SpStrError(result));
+        DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("after write port0,%d returned %s", m_btOutputStatus[0], SpStrError(result));
 
     } else {
 
@@ -569,9 +569,9 @@ void CGpioEntity::WritePin(DWORD dwPinSeq, bool bHighLevel)
         result = m_hDevHelper->WritePort(1, m_btOutputStatus[1]);
         dwEnd = GetTickCount();
         if ((dwEnd - dwStart) > 3000)
-            Dbg("writepin so long.than 3s(%d)", (dwEnd - dwStart));
+            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("writepin so long.than 3s(%d)", (dwEnd - dwStart));
         else
-            Dbg("after write port1,%d returned %s", m_btOutputStatus[1], SpStrError(result));
+            DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("after write port1,%d returned %s", m_btOutputStatus[1], SpStrError(result));
     }
 }
 
@@ -734,7 +734,7 @@ void CGpioEntity::Set(GpioService_Set_Info req)
                 err = spConfig->ReadConfigValueInt("DriverPort", "PrintPaperRed", devicePort2);
             }
             if (err != Error_Succeed) {
-                Dbg("read cfg failed ~.");
+                DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("read cfg failed ~.");
                 return;
             }
             memset(&odi, 0, sizeof(odi));
@@ -753,7 +753,7 @@ Error:
 
     if (err != Error_Succeed)
     {
-        Dbg("read cfg failed.");
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("read cfg failed.");
         return;
     }
 
@@ -768,7 +768,7 @@ Error:
 void CGpioEntity::GetStatus(int deviceSeq, SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
 {
     /** 注意设备序号是实体内定义的逻辑,不是设备端口号*/
-    Dbg("GetStatus with devseq %d", deviceSeq);
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("GetStatus with devseq %d", deviceSeq);
     CSimpleStringA initDriver = "";
     int devicePort;
     ErrorCodeEnum Error;
@@ -835,7 +835,7 @@ bool CGpioEntity::SetOutDriving(GpioService_Set_Info req, OutDrivingInfo od, ULO
             WritePin(pinSeq, m_bHeadLightFlag);
         else {
             if (pinSeq == PIN_HSPSCANNER_PREVIEW_LIGHT) {
-                Dbg("off hspsanner.");
+                DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("off hspsanner.");
                 WritePin(PIN_HSPSCANNER_LIGHT, false);
             }
             WritePin(pinSeq, false);
@@ -853,7 +853,7 @@ bool CGpioEntity::SetOutDriving(GpioService_Set_Info req, OutDrivingInfo od, ULO
             LOG_TRACE("0.0 mode:output[%u], pinSeq=%u", doi.output, pinSeq);
             //if it is hspsanner
             if (pinSeq == PIN_HSPSCANNER_PREVIEW_LIGHT) {
-                Dbg("light hspsanner.");
+                DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("light hspsanner.");
                 WritePin(PIN_HSPSCANNER_LIGHT, true);
             }
             WritePin(pinSeq, true);
@@ -932,9 +932,9 @@ void CGpioEntity::OnPositivePulseUpTimerout(void* pData)
 
     BYTE btInput = 0;
     ErrorCodeEnum err;
-    Dbg("port[%d]", INPUT_PORT_2);
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("port[%d]", INPUT_PORT_2);
     err = m_hDevHelper->ReadPort(INPUT_PORT_2, btInput);
-    Dbg("read[%d]", btInput);
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("read[%d]", btInput);
     //判断输入
     if (DetectBit(btInput, pGCI->index)) {
         if (pGCI->CttPhone == 0)//oiltest 20130709
@@ -995,7 +995,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
         DevErrorInfo devErrInfo;
         ZeroMemory(&devErrInfo, sizeof(DevErrorInfo));
         ErrorCodeEnum erroCode = m_hDevHelper->GetLastErr(devErrInfo);
-        Dbg("ReadPort failed: %s, ErrMsg[%s]", SpStrError(err), (LPCTSTR)devErrInfo.szErrMsg);
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("ReadPort failed: %s, ErrMsg[%s]", SpStrError(err), (LPCTSTR)devErrInfo.szErrMsg);
         return;
     }
 
@@ -1086,7 +1086,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
                 if (m_ePickUpFlag == Unknown) {
                     if (DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = Actived;
                     else if (!DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = InActive;
-                    Dbg("Set initial value: %d", (int)m_ePickUpFlag);
+                    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Set initial value: %d", (int)m_ePickUpFlag);
 
                 } else {
 
@@ -1272,7 +1272,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
             if (m_ePickUpFlag == Unknown) {
                 if (DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = Actived;
                 else if (!DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = InActive;
-                Dbg("Set initial value: %d", (int)m_ePickUpFlag);
+                DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Set initial value: %d", (int)m_ePickUpFlag);
                 break;
             }
 
@@ -1296,8 +1296,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
 
     if (pGci->CttMove > 1 && !bMoveOne) {
         do {
-
-            //Dbg("before ccMove: %d, ccInit: %d, moveRound: %d, %d, disppear: %d, holder: %d",
+            //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("before ccMove: %d, ccInit: %d, moveRound: %d, %d, disppear: %d, holder: %d",
             //    pGci->CttMove, pGci->InitCTT, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
 
             if (m_bMoveRound) {
@@ -1315,14 +1314,14 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
                     pGci->CttMove = pGci->InitCTT;
                 }
             }
-
-            //Dbg("after ccMove: %d, ccInit: %d, moveRound: %d, %d, disppear: %d, holder: %d",
+            
+            //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("after ccMove: %d, ccInit: %d, moveRound: %d, %d, disppear: %d, holder: %d",
             //    pGci->CttMove, pGci->InitCTT, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
 
 
         } while (0);
     } else {
-        //Dbg("===== ccMove: %d, moveOne: %d, moveRound: %d, %d, disppear: %d, holder: %d",
+        //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("===== ccMove: %d, moveOne: %d, moveRound: %d, %d, disppear: %d, holder: %d",
         //    pGci->CttMove, bMoveOne, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
     }
 
@@ -1372,7 +1371,7 @@ bool CGpioEntity::GetReceiving(int deviceSeq, ReceivingInfo ri, ULONG iIndex,
                                SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
 {
 
-    Dbg("inputmode[%d],port[%d],ctt[%d]", ri.InputMode, ri.Port, ri.ContinuousTriggerTime);
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("inputmode[%d],port[%d],ctt[%d]", ri.InputMode, ri.Port, ri.ContinuousTriggerTime);
     switch (ri.InputMode) 
     {
         case IM_POSITIVE_PULSE_UP:
@@ -1437,7 +1436,7 @@ void CGpioEntity::GetOutDrivingModInfo(CSimpleStringA modName, OutDrivingInfo& o
     CSmartPointer<IConfigInfo> spConfig;
     Error = spEntityFunction->OpenConfig(Config_Software, spConfig);
     if (Error != Error_Succeed) {
-        Dbg("open cfg file failed!");
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("open cfg file failed!");
         return;
     }
     spConfig->ReadConfigValueInt(modName, "OutputMode", odi.OutputMode);

+ 4 - 4
Module/mod_gpio/mod_gpio.h

@@ -188,7 +188,7 @@ public:
 
 			GetStatus(PHONEPICKUP,NULL);
 
-			Dbg("subscribelog...");
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("subscribelog...");
 			GetFunction()->SubscribeLog(m_uuidHealth,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"HealthManager");
 			GetFunction()->SubscribeLog(m_uuidIDC,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"IDCertificate");
 			GetFunction()->SubscribeLog(m_uuidFP, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "FingerPrint");
@@ -205,13 +205,13 @@ public:
 			GetFunction()->SubscribeLog(m_uuidPtr, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "Printer");
             GetFunction()->SubscribeLog(m_uuidPrintSeal, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "PrintSeal");
 #endif //RVC_OS_WIN
-			Dbg("subscribelog ok...");
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("subscribelog ok...");
 
 			pTransactionContext->SendAnswer(Error_Succeed);
 		}
 		else
 		{
-			Dbg("gpio open failed(%s).",SpStrError(err));
+			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("gpio open failed(%s).",SpStrError(err));
 			pTransactionContext->SendAnswer(Error_Unexpect);
 		}
 	}
@@ -229,7 +229,7 @@ public:
 		OutDrivingInfo odi;
 		GetOutDrivingModInfo(initDriver,odi);
 		bool bSetFlag = true;
-		Dbg("read port[%u]",(ULONG)driverPort);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("read port[%u]",(ULONG)driverPort);
 		pTransactionContext->SendAnswer(Error_Succeed);
 	}
 

+ 16 - 16
Module/mod_ups/UpsFSM.cpp

@@ -14,7 +14,7 @@ ErrorCodeEnum CUpsFSM::OnInit()
         return result;
     }
     HARDWARE_ENTITY_SET_VENDOR_NAME(m_entCode, pEntity->vendorLibInfo.strVendor);
-    Dbg("vendor library path: %s", (LPCTSTR)dllName);
+    DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("vendor library path: %s", (LPCTSTR)dllName);
 	m_adapterInfo.adapterFileName = dllName;
     result = m_hDevHelper.LoadUp(dllName);
     if (result != Error_Succeed) {
@@ -24,14 +24,14 @@ ErrorCodeEnum CUpsFSM::OnInit()
     CSmartPointer<IConfigInfo> spConfig;
 	result = spEntityFunction->OpenConfig(Config_Root, spConfig);
     if (result != Error_Succeed) {
-        Dbg("open cfg file failed!");
+        DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("open cfg file failed!");
         return result;
     }
 
     int baudRate = 0, port = 0;
     spConfig->ReadConfigValueInt("Device.Ups", "Baudrate", baudRate);
     spConfig->ReadConfigValueInt("Device.Ups", "Port", port);
-    Dbg("port: %d, baudrate: %d", port, baudRate);
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("port: %d, baudrate: %d", port, baudRate);
 	result = m_hDevHelper->DevOpen(port, baudRate);
     if (result != Error_Succeed) {
 		SetErrPackage(m_errPkg, "OnInit::DevOpen", m_csDevNo, result, MEC_DEVAPI_UPS_DevOpen);
@@ -39,7 +39,7 @@ ErrorCodeEnum CUpsFSM::OnInit()
 		return result;
     }
 
-    Dbg("open ups succeed.");
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("open ups succeed.");
     m_bDevOpen = true;
 	ZeroMemory(m_devCatInfo.szModel, sizeof(m_devCatInfo.szModel));
 	ZeroMemory(m_devCatInfo.szType, sizeof(m_devCatInfo.szType));
@@ -47,9 +47,9 @@ ErrorCodeEnum CUpsFSM::OnInit()
 	result = m_hDevHelper->GetDevCategory(m_devCatInfo);
 	if (result == Error_Succeed)
 	{
-		Dbg("szVendor:%s", m_devCatInfo.szVendor);
-		Dbg("szType:%s", m_devCatInfo.szType);
-		Dbg("szModel:%s", m_devCatInfo.szModel);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("szVendor:%s", m_devCatInfo.szVendor);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("szType:%s", m_devCatInfo.szType);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("szModel:%s", m_devCatInfo.szModel);
 		m_adapterInfo.devCatInfo = m_devCatInfo;
 	}
 	else {
@@ -73,7 +73,7 @@ void CUpsFSM::s0_on_entry()
 	if (eErrCode != Error_Succeed) {
 		LOG_UPS_ERROR_MSG_MACRO(eErrCode, GetDevStatus);
 	} else {
-		Dbg("UpsState: %d", eUpsState);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("UpsState: %d", eUpsState);
 	}
 	m_testResult = Error_Succeed;
 
@@ -105,10 +105,10 @@ unsigned int CUpsFSM::s0_on_event(FSMEvent* e)
 			e->SetHandled();
 			UpsStatusEnum eUpsState;
 			ErrorCodeEnum eErrState = m_hDevHelper->GetDevStatus(eUpsState);
-			Dbg("%s,%d",SpStrError(eErrState), eUpsState);
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s,%d",SpStrError(eErrState), eUpsState);
 			GetStatusEvent* pGse = dynamic_cast<GetStatusEvent*>(e);
 			pGse->ctx->Ans.Status = eUpsState;
-			Dbg("status: %d",pGse->ctx->Ans.Status);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("status: %d",pGse->ctx->Ans.Status);
 			pGse->ctx->Answer(eErrState);
 		}
 		break;
@@ -168,18 +168,18 @@ int CUpsFSM::ShutDown(SpReqAnsContext<UpsService_Shutdown_Req,UpsService_Shutdow
 	LOG_FUNCTION();
 
 	UpsStatusEnum eUpsStatus;
-    Dbg("shutdown time: %d, uptime: %d", ctx->Req.ShutdownTime, ctx->Req.UpTime);
+    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("shutdown time: %d, uptime: %d", ctx->Req.ShutdownTime, ctx->Req.UpTime);
 	ErrorCodeEnum err = m_hDevHelper->GetDevStatus(eUpsStatus);
-	Dbg("(%s)status:[%d],%d,%d",SpStrError(err), eUpsStatus, ctx->Req.ShutdownTime, ctx->Req.UpTime);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("(%s)status:[%d],%d,%d",SpStrError(err), eUpsStatus, ctx->Req.ShutdownTime, ctx->Req.UpTime);
     if (ctx->Req.ShutdownTime < 0 || ctx->Req.UpTime < 0) {
-        Dbg("error param");
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("error param");
         ctx->Answer(Error_Param);
         return 2; //do not jump
     }
 	err = m_hDevHelper->Shutdown(ctx->Req.ShutdownTime,ctx->Req.UpTime);
 	if (err == Error_Succeed)
 	{
-		Dbg("shutdown...");
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("shutdown...");
 		ctx->Answer(Error_Succeed);
 		return 0;
 	}
@@ -202,7 +202,7 @@ int CUpsFSM::CheckStatus()
 			eErr = m_hDevHelper->GetDevStatus(eUpsStatus);
 			if (eErr == Error_Succeed)
 			{
-				Dbg("CheckStatus %d",eUpsStatus);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CheckStatus %d",eUpsStatus);
 				if (eUpsStatus == UPS_STATUS_NORMAL || eUpsStatus == UPS_STATUS_NO_ELECTOR)
 					return 0;
 			}
@@ -211,7 +211,7 @@ int CUpsFSM::CheckStatus()
 		i++;
 		if (i > 30)
 		{
-			Dbg("have try 5 minutes.");
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("have try 5 minutes.");
 			i = 0;
 		}
 	}

+ 7 - 7
Module/mod_watchdog/WatchDogFSM.cpp

@@ -36,7 +36,7 @@ void CWatchDogFSM::s0_on_exit()
 
 unsigned int CWatchDogFSM::s0_on_event(FSMEvent* pEvt)
 {
-	Dbg("s0 evt %d",pEvt->iEvt);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("s0 evt %d",pEvt->iEvt);
 	int rt = 0;
 	switch(pEvt->iEvt)
 	{
@@ -121,7 +121,7 @@ unsigned int CWatchDogFSM::s2_on_event(FSMEvent* evt)
 		{
 			if (evt->param1 != 0)
 			{
-				Dbg("Refresh failed(%d).",evt->param1);
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Refresh failed(%d).",evt->param1);
 				rt = 1;
 			}
 			else
@@ -157,7 +157,7 @@ void CWatchDogFSM::s3_on_exit()
 }
 unsigned int CWatchDogFSM::s3_on_event(FSMEvent* pEvt)
 {
-	Dbg("s3 evt %d",pEvt->iEvt);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("s3 evt %d",pEvt->iEvt);
 	int rt = 0;
 	switch(pEvt->iEvt)
 	{
@@ -210,7 +210,7 @@ ErrorCodeEnum CWatchDogFSM::Load()
 
     HARDWARE_ENTITY_SET_VENDOR_NAME(m_entCode, pEntity->vendorLibInfo.strVendor);
 
-	Dbg("vendor library path: %s", (LPCTSTR)dllName);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("vendor library path: %s", (LPCTSTR)dllName);
 	result = m_hDevHelper.LoadUp(dllName);
 	if (result != Error_Succeed) {
 		return result;
@@ -225,7 +225,7 @@ ErrorCodeEnum CWatchDogFSM::Load()
 		result = m_hDevHelper->GetDevCategory(m_devCatInfo);
 		if (result == Error_Succeed)
 		{
-			Dbg("szVendor:%s ,szType:%s szModel:%s", m_devCatInfo.szVendor, m_devCatInfo.szType, m_devCatInfo.szModel);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("szVendor:%s ,szType:%s szModel:%s", m_devCatInfo.szVendor, m_devCatInfo.szType, m_devCatInfo.szModel);
 			m_adapterInfo.devCatInfo = m_devCatInfo;
 		}
 		else {
@@ -242,9 +242,9 @@ ErrorCodeEnum CWatchDogFSM::Load()
 }
 int CWatchDogFSM::StartWatch(SpReqAnsContext<WatchDogService_StartWatch_Req,WatchDogService_StartWatch_Ans>::Pointer ctx)
 {
-	Dbg("fsm starwatch %d,%d", ctx->Req.Delay, ctx->Req.Timeout);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("fsm starwatch %d,%d", ctx->Req.Delay, ctx->Req.Timeout);
 	if (ctx->Req.Delay < 0 || ctx->Req.Timeout < 0) {
-		Dbg("error param");
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("error param");
 		ctx->Answer(Error_Param);
 		return 2;
 	}