void CLog::LogToFile( const S_LogMsg& logMsg ) { // 日志信息格式化, 统一添加一些格式化的信息(如日期) const TString& strLogMsg = FormMsg( logMsg.strMsg ); // 类型判断 if ( logMsg.eType <= eERROR_MSG_TYPE_START || logMsg.eType >= eErrLog ) { // bad, 日志类型不合法 ErrLogMsg( logMsg.eType, strLogMsg, _T("Err Log Type") ); return; } // 日志文件获得 const SOpenFile* pOpenFlil = GetLogFile( logMsg.eType ); if ( pOpenFlil == NULL ) { // bad, 日志文件获得失败 ErrLogMsg( logMsg.eType, strLogMsg, _T("Cannot open logFile") ); return; } // 输出 if ( WriteFile( pOpenFlil->pFile, strLogMsg ) == false ) { // bad, 日志写入失败 ErrLogMsg( logMsg.eType, strLogMsg, _T("Write logFile failed!") ); return; } }
void CConnClient::OnServerCommand(const CGas2GacGC_Tell_Guids* pCmd) { str_guid_t szGuidServer; str_guid_t szGuidConnection; GuidToString(pCmd->guidConnection, szGuidConnection); ErrLogMsg("Conn Guid", szGuidConnection); GuidToString(pCmd->guidServer, szGuidServer); ErrLogMsg("Server GUID", szGuidServer); m_pSlowSigner = new CSlowSigner( pCmd->guidConnection ); //memcpy( m_guidConn , pCmd->guidConnection , sizeof( m_guidConn) ); CAddress address; if (GetRemoteAddress(address)) { string strAddr; address.GetAddressAndPort(strAddr); ErrLogMsg("Server Addr", strAddr.c_str()); } if (GetLocalAddress(address)) { string strAddr; address.GetAddressAndPort(strAddr); ErrLogMsg("Client Addr", strAddr.c_str()); } }