123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706 |
- #include "stdafx.h"
- #include "UpLogFSM.h"
- #include "Event.h"
- UpLogFSM::UpLogFSM() : m_pConnection(NULL),m_isSendLog(false),m_branchSendLog(false),m_logTypeList("")
- {
- InitializeCriticalSection(&cs);
- InitializeCriticalSection(&csRec);
- m_SendMode=0;//默认是单条传送
- m_iSub=0;//订阅总数
- m_iRec=0;//队列接收总数
- m_iSend=0;//队列发送总数
- m_iThrow=0;//队列丢弃总数
- m_iFail=0;//发送失败总次数
- m_iSucc=0;//发送成功总次数
- m_iEachSend=0;//每次连接发送的数量
- m_iEachMaxSend=100;//每次连接最大发送次数
- }
- UpLogFSM::~UpLogFSM()
- {
- EnterCriticalSection(&cs);
- while(true){
- if(m_logList.empty()){
- break;
- }else{
- log_t* dLog = (log_t*)(*m_logList.begin());//集合首个元素
- m_logList.erase(m_logList.begin());//集合删除首元素
- delLog(dLog);//释放内存
- }
- }
- LeaveCriticalSection(&cs);
- DeleteCriticalSection(&cs);
- DeleteCriticalSection(&csRec);
- }
- void UpLogFSM::OnStateTrans( int iSrcState, int iDstState )
- {
- printDebugLog(CSimpleStringA::Format("trans from %s to %s", GetStateName(iSrcState), GetStateName(iDstState)));
- //Dbg("trans from %s to %s", GetStateName(iSrcState), GetStateName(iDstState));
- }
- void UpLogFSM::OnSysVarEvent( const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName )
- {
- }
- ErrorCodeEnum UpLogFSM::OnInit()
- {
- AddStateHooker(this);
- //......
- CSmartPointer<IEntityFunction> spFunction = m_pEntity->GetFunction();
- CSmartPointer<IConfigInfo> spConfig;
-
- ErrorCodeEnum Error = spFunction->OpenConfig(Config_CenterSetting, spConfig);
- if (Error_Succeed == Error)
- {
- int branchSendLog = 0;
- Error = spConfig->ReadConfigValueInt("UpLog", "BranchSendLog", branchSendLog);//全分行是否上传日志
- if (Error_Succeed == Error)
- {
- //Dbg("get BranchSendLog=%d from CenterSetting.ini", branchSendLog);
- printDebugLog(CSimpleStringA::Format("get BranchSendLog=%d from CenterSetting.ini", branchSendLog));
- m_branchSendLog = branchSendLog==1 ? true : false ;//整个分行所有终端是否需要上传日志标志位
- }
- else
- {
- //Dbg("get [UpLog].BranchSendLog from CenterSetting.ini failed");
- printDebugLog(CSimpleStringA::Format("get [UpLog].BranchSendLog from CenterSetting.ini failed"));
- }
- if(m_branchSendLog){
- m_isSendLog=true;
- }else{
- CSimpleStringA TerminalList ="";
- Error = spConfig->ReadConfigValue("UpLog", "TerminalList", TerminalList);//某些终端是否上传日志
- if (Error_Succeed == Error)
- {
- //Dbg("get TerminalList=%s from CenterSetting.ini", TerminalList);
- printDebugLog(CSimpleStringA::Format("get TerminalList=%s from CenterSetting.ini", TerminalList));
- CSystemStaticInfo systemStaticInfo;
-
- auto rc = this->m_pEntity->GetFunction()->GetSystemStaticInfo(systemStaticInfo);
- assert(rc == Error_Succeed);
- CAutoArray<CSimpleStringA> tList = TerminalList.Split('|');
- for(int i=0; i<tList.GetCount(); i++){
- if(tList[i]==systemStaticInfo.strTerminalID){
- m_isSendLog=true;
- break;
- }
- }
- }
- else
- {
- //Dbg("get [UpLog].TerminalList from CenterSetting.ini failed");
- printDebugLog(CSimpleStringA::Format("get [UpLog].TerminalList from CenterSetting.ini failed"));
- }
- }
- //Dbg("m_isSendLog = %d ",m_isSendLog);
- printDebugLog(CSimpleStringA::Format("m_isSendLog = %d ",m_isSendLog));
- CSimpleStringA LogTypeList ="";
- Error = spConfig->ReadConfigValue("UpLog", "LogType", LogTypeList); //某些日志类型是否上传
- if (Error_Succeed == Error)
- {
- //Dbg("get LogTypeList=%s from CenterSetting.ini", LogTypeList);
- printDebugLog(CSimpleStringA::Format("get LogTypeList=%s from CenterSetting.ini", LogTypeList));
- CSimpleStringA temp = "";
- if(LogTypeList==""){
- //空值默认全部类型上传
- char buff[10] ={0} ;
- sprintf(buff,"%d;%d;%d;%d;",(int)Log_Event,(int)Log_Warning,(int)Log_Error,(int)Log_Debug);
- temp +=buff;
- }else{
- //根据类型值组合上传类型Event|Warn|Debug|Error
- CAutoArray<CSimpleStringA> tList = LogTypeList.Split('|');
- for(int i=0; i<tList.GetCount(); i++){
- if(tList[i]=="Event"){
- char buff[4] ={0} ;
- sprintf(buff,"%d;",(int)Log_Event);
- temp +=buff;
- }else if(tList[i]=="Warn"){
- char buff[4] ={0} ;
- sprintf(buff,"%d;",(int)Log_Warning);
- temp +=buff;
- }else if(tList[i]=="Debug"){
- char buff[4] ={0} ;
- sprintf(buff,"%d;",(int)Log_Debug);
- temp +=buff;
- }else if(tList[i]=="Error"){
- char buff[4] ={0} ;
- sprintf(buff,"%d;",(int)Log_Error);
- temp +=buff;
- }
- }
- }
-
- m_logTypeList = temp;
- //Dbg("m_logTypeList =%s", m_logTypeList);
- printDebugLog(CSimpleStringA::Format("m_logTypeList =%s", m_logTypeList));
- }
- else
- {
- //Dbg("get [UpLog].LogTypeList from CenterSetting.ini failed");
- printDebugLog(CSimpleStringA::Format("get [UpLog].LogTypeList from CenterSetting.ini failed"));
- }
- int SendMode = 0;
- Error = spConfig->ReadConfigValueInt("UpLog", "SendMode", SendMode); //发送模式:0 单条发送 1 批量发送(最大32k)
- if (Error_Succeed == Error){
- m_SendMode = SendMode;
- //Dbg("get m_SendMode = %d", SendMode);
- printDebugLog(CSimpleStringA::Format("m_SendMode = %d", SendMode));
- }else{
- //Dbg("get [UpLog].SendMode from CenterSetting.ini failed");
- printDebugLog(CSimpleStringA::Format("get [UpLog].SendMode from CenterSetting.ini failed"));
- }
- if(m_SendMode==0){
- m_iEachMaxSend =EACH_SEND_COUNT_SINGLE;
- }else{
- m_iEachMaxSend =EACH_SEND_COUNT_MULTI;
- }
- //Dbg("m_iEachConnSum = %d",m_iEachConnSum);
- printDebugLog(CSimpleStringA::Format("m_iEachMaxSend = %d",m_iEachMaxSend));
- }else{
- //Dbg("open CenterSetting.ini failed");
- printDebugLog(CSimpleStringA::Format("open CenterSetting.ini failed"));
- return Error_Exception;
- }
- return Error_Succeed;
- }
- ErrorCodeEnum UpLogFSM::OnExit()
- {
- return Error_Succeed;
- }
- void UpLogFSM::s0_on_entry()
- {
- if(m_isSendLog){
- PostEventLIFO(new FSMEvent(USER_EVT_JMP_CONNECT));//跳转到S1状态
- }else{
- Dbg("不需要上收日志数据,等待60s");
- ScheduleTimer(1, 60000);
- }
-
- }
- void UpLogFSM::s0_on_exit()
- {
- CancelTimer(1);
- }
- unsigned int UpLogFSM::s0_on_event( FSMEvent* event )
- {
- if (event->iEvt == EVT_TIMER)
- {
- if(m_isSendLog){
- PostEventLIFO(new FSMEvent(USER_EVT_JMP_CONNECT));//跳转到S1状态
- }else{
- Dbg("不需要上收日志数据,等待60s");
- ScheduleTimer(1, 60000);
- }
- }
- return 0;
- }
- void UpLogFSM::s1_on_entry()
- {
- if (!m_pConnection) {
- m_pConnection = new UpLogConnection(m_pEntity, this);
-
- if(m_pConnection->ConnectFromCentralSetting() && m_pConnection->IsConnectionOK()){
- //创建成功
- }else{
- //创建失败
- printDebugLog(CSimpleStringA::Format("连接日志上收分行服务失败"));
- m_pConnection->Close();
- m_pConnection->DecRefCount();
- m_pConnection = NULL;
- }
- }
- if (!m_pConnection)
- {
- ScheduleTimer(2, 10000); // try 10 seconds later
- }
- else
- {
- PostEventLIFO(new FSMEvent(USER_EVT_JMP_SENDLOG));//跳转S2状态
- }
- }
- void UpLogFSM::s1_on_exit()
- {
- CancelTimer(2);
- }
- unsigned int UpLogFSM::s1_on_event(FSMEvent* event)
- {
- if (event->iEvt == EVT_TIMER)
- {
- m_pConnection = new UpLogConnection(m_pEntity, this);
- if(m_pConnection->ConnectFromCentralSetting()&&m_pConnection->IsConnectionOK()){
- //创建成功
- }else{
- printDebugLog(CSimpleStringA::Format("连接日志上收分行服务失败"));
- m_pConnection->Close();
- m_pConnection->DecRefCount();
- m_pConnection = NULL;
- }
- if (!m_pConnection)
- {
- ScheduleTimer(2, 10000); // try 10 seconds later
- }
- else {
- PostEventLIFO(new FSMEvent(USER_EVT_JMP_SENDLOG));//跳转S2状态
- }
- }
- return 0;
- }
- void UpLogFSM::s2_on_entry()
- {
- if(m_isSendLog){
- if(m_logList.empty()){
- PostEventLIFO(new FSMEvent(USER_EVT_DISCONNECT_FAIL));//为空时,等待10s再传
- }else{
- m_iEachSend = 0;
- //打印每次发送统计记录;
- //Dbg("send log statistic m_iRec=%d , m_iThrow=%d , m_iSend=%d , m_iSucc=%d , m_iFail=%d",m_iRec,m_iThrow,m_iSend,m_iSucc,m_iFail);
- int unSend = m_logList.size();
- printDebugLog(CSimpleStringA::Format("send log statistic m_iRec=%d , m_iThrow=%d , UnSend=%d , m_iSend=%d , m_iSucc=%d , m_iFail=%d",m_iRec,m_iThrow,unSend,m_iSend,m_iSucc,m_iFail));
- m_pConnection->SendLog();
- m_iEachSend++;
- }
- }else{
- PostEventLIFO(new FSMEvent(USER_EVT_JMP_START));//跳转S0状态
- }
- }
- void UpLogFSM::s2_on_exit()
- {
- CancelTimer(3);
- }
- unsigned int UpLogFSM::s2_on_event(FSMEvent* event)
- {
- if (event->iEvt == EVT_TIMER){
- PostEventLIFO(new FSMEvent(USER_EVT_JMP_CONNECT));//跳转S1状态
- }else if (event->iEvt == USER_EVT_UPLOG_ANS){
-
- UpLogAnsEvent *ans = (UpLogAnsEvent *)event;
-
- //发送个数控制长连接时间
- if (ans->m_reply.ResultCode == UpLogCtlCode::Finish)
- {
- m_iSucc++;//成功
- }else if (ans->m_reply.ResultCode == UpLogCtlCode::Error)
- {
- m_iFail++;//失败
- }
- if(m_iEachSend<m_iEachMaxSend){
- if(m_logList.empty()){
- //Dbg("返回报文结果:%d",ans->m_reply.ResultCode);
- Dbg("队列已空");
- //printDebugLog(CSimpleStringA::Format("返回报文结果:%d",ans->m_reply.ResultCode));//不能加入队列,否则不断循环
- PostEventLIFO(new FSMEvent(USER_EVT_DISCONNECT_FAIL));//为空时,等待10s再传
- }else{
- m_pConnection->SendLog();
- m_iEachSend++;
- }
- }else{
- PostEventLIFO(new FSMEvent(USER_EVT_DISCONNECT_SUCC));//正常退出
- }
- }else if (event->iEvt == USER_EVT_DISCONNECT_SUCC) {
- //正常退出,等待3s时间返回S1
- if(m_pConnection!=NULL){
- m_pConnection->Close();
- m_pConnection->DecRefCount();
- m_pConnection = NULL;
- }
- ScheduleTimer(3, CONNECT_SUCC_WAIT_TIME); // try 3 seconds later
- }else if (event->iEvt == USER_EVT_DISCONNECT_FAIL) {
- //异常退出,等待10s时间返回S1
- if(m_pConnection!=NULL){
- m_pConnection->Close();
- m_pConnection->DecRefCount();
- m_pConnection = NULL;
- }
- ScheduleTimer(3, CONNECT_FAIL_WAIT_TIME); // try 10 seconds later
- }
-
- return 0;
- }
- void UpLogFSM::addUplog( log_t* logt )
- { //加锁,队列满了,把前面的丢弃,新的补充进来,注意释放内存空间
- EnterCriticalSection(&cs);
- if(m_logList.size()>=UPLOG_MAX_COUNT){
- //Dbg("queue is full,delete log,EntityName=%s,Msg=%s,SN=%d",dLog->EntityName,dLog->Msg,dLog->SN);
- log_t* dLog = (log_t*)(*m_logList.begin());//集合首个元素
- m_logList.erase(m_logList.begin());//集合删除首元素
- delLog(dLog);//释放内存
- m_iThrow++;
- }
- m_logList.push_back(logt);//加入队列
- LeaveCriticalSection(&cs);
- }
- log_t* UpLogFSM::removeUplog()
- {//加锁,取出先进的队列日志,注意释放内存空间
- log_t* dLog = NULL;
- EnterCriticalSection(&cs);
- if(m_logList.empty()){
- }else{
- dLog = (log_t*)(*m_logList.begin());//集合首个元素
- m_logList.erase(m_logList.begin());//集合删除首元素
- }
- LeaveCriticalSection(&cs);
- return dLog;//返回
- }
- bool UpLogFSM::isType(const LogTypeEnum eLogTyp)
- {
- char buff[4] ={0} ;
- sprintf(buff,"%d",(int)eLogTyp);
- if(m_logTypeList.IndexOf(buff)==-1){
- return false;
- }else{
- return true;
- }
- }
- void UpLogFSM::delLog( log_t* logt )
- {
- if(logt==NULL){
- return;
- }
- if(logt->EntityName!=NULL){
- free(logt->EntityName);
- logt->EntityName=NULL;
- }
- if(logt->Msg!=NULL){
- free(logt->Msg);
- logt->Msg=NULL;
- }
- if(logt->TerminalNo!=NULL){
- free(logt->TerminalNo);
- logt->TerminalNo=NULL;
- }
- if(logt->LogTime!=NULL){
- free(logt->LogTime);
- logt->LogTime=NULL;
- }
- if(logt->Item!=NULL){
- free(logt->Item);
- logt->Item=NULL;
- }
- if(logt->SysCode!=NULL){
- free(logt->SysCode);
- logt->SysCode=NULL;
- }
- if(logt->UserCode!=NULL){
- free(logt->UserCode);
- logt->UserCode=NULL;
- }
- delete logt;
- logt=NULL;
- return;
- }
- char* UpLogFSM::mallocStr( const char* s)
- {
- char* temp =NULL;
- if(s && (temp=(char*)malloc(strlen(s)+1))){
- memset(temp,0,strlen(s)+1);
- strcpy(temp,s);
- }
- return temp;
- }
- int UpLogFSM::getEntityRow( const char* entityName )
- {
- if(entityName==NULL){
- return 0;
- }
- CSimpleStringA findstr = entityName;
- map<CSimpleString,int>::iterator iter;
- iter = m_entityRowSet.find(findstr);
- if(iter!=m_entityRowSet.end()){
- (iter->second)++;
- return iter->second;
- }else{
- m_entityRowSet.insert(make_pair(findstr,1));
- return 1;
- }
-
- }
- bool UpLogFSM::getJsonStr( UpLogReq1* req )
- {
- //单条获取
- //Dbg("队列消息数目=%d",m_logList.size());
- //printDebugLog(CSimpleStringA::Format("队列消息数目=%d",m_logList.size()));
- log_t* logt = removeUplog();//注意释放内存
- if(logt==NULL){
- return false;
- }else{
- //单条记录转换为json报文
- Json::Value root;
- Json::Value arraylist;//消息列表
- Json::Value MsgObject;//消息对象
- Json::FastWriter fw;//写入对象
- root["interface"]="singleLog";
- MsgObject["TerminalNo"]= logt->TerminalNo;
- MsgObject["EntityName"]= logt->EntityName;
- MsgObject["Item"]= logt->Item;
- MsgObject["Time"]= logt->LogTime;
- MsgObject["TimeSn"]= logt->SN;
- MsgObject["SysCode"]= logt->SysCode;
- MsgObject["UserCode"]= logt->UserCode;
- MsgObject["LogType"]= logt->LogType;
- MsgObject["Level"]= logt->Level;
- MsgObject["msg"]= logt->Msg;
- int i=0;
- arraylist[i]= MsgObject;
- root["msgList"] = arraylist;
- string jsonStr = fw.write(root);
- strncpy(req->TerminalNo,logt->TerminalNo,sizeof(req->TerminalNo)-1);//拷贝终端号
- delLog(logt);//释放内存
- //Dbg("转换的json报文,len=%d,内容=%s",jsonStr.length(),jsonStr.c_str());
- if(!jsonStr.empty()){
- req->logLen= jsonStr.length();
- strncpy(req->logdata,jsonStr.c_str(),sizeof(req->logdata)-1);//最大不超过2k
- return true;
- }else{
- return false;
- }
- }
- }
- bool UpLogFSM::getJsonStr( UpLogReq2* req )
- {
- //动态根据接口长度组装json报文
- int i = 0;
- Json::Value root;
- Json::Value arraylist;//消息列表
- Json::FastWriter fw;//写入对象
- root["interface"]="multiLog";
- string jsonStr="" ;
- while(true){
- log_t* logt = removeUplog();//注意释放内存
- if(logt==NULL){
- break;
- }else{
- Json::Value MsgObject;//消息对象
- MsgObject["TerminalNo"]= logt->TerminalNo;
- MsgObject["EntityName"]= logt->EntityName;
- MsgObject["Item"]= logt->Item;
- MsgObject["Time"]= logt->LogTime;
- MsgObject["TimeSn"]= logt->SN;
- MsgObject["SysCode"]= logt->SysCode;
- MsgObject["UserCode"]= logt->UserCode;
- MsgObject["LogType"]= logt->LogType;
- MsgObject["Level"]= logt->Level;
- MsgObject["msg"]= logt->Msg;
- arraylist[i]=MsgObject;
- root["msgList"] = arraylist;
- jsonStr = fw.write(root);//动态增长
- //Dbg("jsonStr lenth is %d",jsonStr.length());
- strncpy(req->TerminalNo,logt->TerminalNo,sizeof(req->TerminalNo)-1);//拷贝终端号
- delLog(logt);//释放内存
- //Dbg("转换的json报文,len=%d,内容=%s",jsonStr.length(),jsonStr.c_str());
- if(jsonStr.length()>14*1024){
- break;
- }else{
- i++;//加一
-
- }
- }
- }
- Dbg("一次发送=%d",i);
- //printDebugLog(CSimpleStringA::Format("一次发送条数=%d",i));//不能加入发送队列,否则不断循环
- if(!jsonStr.empty()){
- //Dbg("转换的json报文:%s",jsonStr.c_str());
- req->logLen = jsonStr.length();
- strncpy(req->logdata,jsonStr.c_str(),sizeof(req->logdata)-1);//最大不超过16k
- return true;
- }else{
- return false;
- }
- }
- //使用此方法注意不要陷入死循环加入日志到队列中
- void UpLogFSM::printDebugLog( const char* debugStr )
- {
-
- Dbg("uplog:%s",debugStr);
- //主动添加到消息队列中
- string entityName = this->m_pEntity->GetEntityName();
- log_t* logt = new log_t();
- memset(logt,0,sizeof(log_t));
- bool succ = true;
- CSystemStaticInfo systemStaticInfo;
- CSmartPointer<IEntityFunction> spFunction = m_pEntity->GetFunction();
- ErrorCodeEnum Error = spFunction->GetSystemStaticInfo(systemStaticInfo);
- char* cTerminalNo=NULL;
- if(Error_Succeed == Error){
- cTerminalNo = mallocStr(systemStaticInfo.strTerminalID.GetData());
- }else{
- string temp = "0000000000";
- cTerminalNo = mallocStr(temp.c_str());
- }
- if(cTerminalNo!=NULL){
- logt->TerminalNo = cTerminalNo;//终端号,记得释放
- }else{
- succ=false;
- }
-
- char* cEntityName = mallocStr(entityName.c_str());
- if(cEntityName!=NULL){
- logt->EntityName = cEntityName;//实体名,记得释放
- }else{
- succ=false;
- }
- char* clogTime = (char*)malloc(30);
- if(clogTime!=NULL){
- memset(clogTime,0,30);//2020-20-20 12:12:12.100 日志时间,记得释放
- SYSTEMTIME st ;
- GetLocalTime(&st);
- sprintf(clogTime, "%04d-%02d-%02d %02d:%02d:%02d.%03d", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
- logt->LogTime =clogTime;
- }else{
- succ=false;
- }
- char* cMsg = mallocStr(debugStr);
- if(cMsg!=NULL){
- logt->Msg = cMsg;//日志消息,记得释放
- }else{
- succ=false;
- }
-
- char* cEntityInstanceID = (char*)malloc(20);
- if (cEntityInstanceID!=NULL)
- {
- memset(cEntityInstanceID,0,20);
- CEntityRunInfo eri = {0};
- ErrorCodeEnum ec = GetEntityBase()->GetFunction()->GetSelfEntityRunInfo(eri);
- if(ec == Error_Succeed)
- {
- ultoa(eri.dwEntityInstanceID,cEntityInstanceID,10);//实体ID,记得释放
- logt->Item = cEntityInstanceID;
- }else{
- logt->Item = cEntityInstanceID;//实体ID,记得释放
- }
- }else{
- succ=false;
- }
- char* cSysError = (char*)malloc(20);
- if (cSysError!=NULL)
- {
- memset(cSysError,0,20);
- ultoa(0xffff,cSysError,16);//系统errorcode,记得释放
- logt->SysCode=cSysError;
- }else{
- succ=false;
- }
- char* cUserCode = (char*)malloc(20);
- if (cUserCode!=NULL)
- {
- memset(cUserCode,0,20);
- ultoa(0xffff,cUserCode,16);//用户定义Usercode,记得释放
- logt->UserCode = cUserCode;
- }else{
- succ=false;
- }
- logt->LogType = (int)LogTypeEnum::Log_Debug;
- logt->Level = (int)SeverityLevelEnum::Severity_Low;
- int iRow = getEntityRow(entityName.c_str());
- logt->SN =iRow;
- addRecSum();
- if(!succ){
- delLog(logt);//删除元素内存
- return;
- }else{
- addUplog(logt);//加入日志到列表
- }
- }
- void UpLogFSM::addRecSum()
- {
- EnterCriticalSection(&csRec);
- m_iRec++;
- LeaveCriticalSection(&csRec);
- }
|