|
-
- #include "Stdafx.h"
- #include "Commend.h"
- #include <strsafe.h>
- #include "GameServerDlg.h"
-
- bool mylog::ToSet(TCHAR* pBuffer, int iLen, DWORD dUserID)
- {
- TCHAR* szTemp = NULL;
- try
- {
- if (wcslen(pBuffer) == 0) return true;
- szTemp = (TCHAR*)malloc(iLen);
- ZeroMemory(szTemp, iLen);
- TCHAR szKey[512] = { 0 };
- CString csTest = pBuffer;
- bool bFind = false;
-
- if(csTest.Replace(_T("->"),_T("<br><font color=#888888>")))
- {
- bFind = true;
- }
-
- StringCchCopy(pBuffer, iLen / sizeof(TCHAR), csTest.GetBuffer(0));
- csTest.ReleaseBuffer();
-
- CTime m_time;
- m_time=CTime::GetCurrentTime(); //获取当前时间日期
- CString m_strDateTime = m_time.Format(_T("%Y-%m-%d %H:%M:%S %A")); //格式化日期时间
-
- #ifdef _UNICODE
- _snwprintf(szKey, 512, TEXT("【%d】发生时间:%s"), dUserID, m_strDateTime);
- _snwprintf(szTemp, iLen / sizeof(TCHAR), TEXT("<p style='font-size:9pt;' class=\"%d\"><br>-----------------------------------------------------<br><font color=red>"), dUserID);
- #else
- _snprintf(szKey, 512, TEXT("【%d】发生时间:%s"), dUserID, m_strDateTime);
- _snprintf(szTemp, iLen / sizeof(TCHAR), TEXT("<p style='font-size:9pt;' class=\"%d\"><br>-----------------------------------------------------<br><font color=red>"), dUserID);
- #endif
- StringCchCat(szTemp, iLen / sizeof(TCHAR), TEXT("【协议】"));
- StringCchCat(szTemp, iLen / sizeof(TCHAR), szKey);
- StringCchCat(szTemp, iLen / sizeof(TCHAR), TEXT("</font><br><font color=green>"));
- StringCchCat(szTemp, iLen / sizeof(TCHAR), pBuffer);
- if (bFind) StringCchCat(szTemp, iLen / sizeof(TCHAR), TEXT("</font></font></p>"));
- else StringCchCat(szTemp, iLen / sizeof(TCHAR), TEXT("</font></p>"));
- StringCchCopy(pBuffer, iLen / sizeof(TCHAR), szTemp);
-
- free(szTemp);
- szTemp = NULL;
- }
- catch (CMemoryException* e)
- {
- if (szTemp)
- {
- free(szTemp);
- szTemp = NULL;
- }
- }
-
- pBuffer[iLen - 1] = 0;
- return true;
- }
-
- void mylog::OutputString(TCHAR* pBuffer, int iTableID)
- {
- //检查日志是否启用
- if (!CGameServerDlg::g_bGameLog) return;
-
- Commend::AddLog(iTableID, pBuffer);
- //OutputDebugString(pBuffer);
- }
|