void LogGenteBanned(std::string Nombre) { std::stringstream f; f << Nombre << std::endl; Logger::getInstance().log(GetLogFileName("GenteBanned"),f.str()); // bans se flushean inmediatamente Logger::getInstance().flush(GetLogFileName("GenteBanned")); }
void LogCriticalHackAttemp(std::string texto) { std::stringstream f; f << vb6::Now() << " " << texto << std::endl; Logger::getInstance().log(GetLogFileName("criticalhack"),f.str()); // cheats se flushean inmediatamente Logger::getInstance().flush(GetLogFileName("criticalhack")); }
void LogBanFromName(std::string BannedName, int UserIndex, std::string Motivo) { WriteVar(GetLogFileName("BanDetail"), BannedName, "BannedBy", UserList[UserIndex].Name); WriteVar(GetLogFileName("BanDetail"), BannedName, "Reason", Motivo); LogGenteBanned(BannedName); }
void LogError(std::string desc) { std::stringstream f; f << vb6::Now() << " " << desc << std::endl; std::cerr << f.str() << std::endl; Logger::getInstance().log(GetLogFileName("errores"),f.str()); // errores se flushean inmediatamente Logger::getInstance().flush(GetLogFileName("errores")); }
void CLogActions::AddMsgLogLineRaw(const char* szTargetLog,const char *sBuffer, const char *sBuffer2) { if(objSettings.SaveMesNotesByDef){ AddLogLine(GetLogFileName(DEFAULT_GENERALLOG), sBuffer, objSettings.dwMaxLogFileSize, sBuffer2); if(objSettings.SaveMesNotesByDefForUser && strcmp(szTargetLog,DEFAULT_GENERALLOG)!=0){ AddLogLine(GetLogFileName(szTargetLog), sBuffer, objSettings.dwMaxLogFileSize, sBuffer2); } } }
void LogBugReport(int UserIndex, const std::string& s) { std::stringstream f; f << "[" << vb6::Now() << "] Ususario: " << UserList[UserIndex].Name << std::endl; f << s << std::endl; f << std::endl; Logger::getInstance().log(GetLogFileName("bugs"),f.str()); // errores se flushean inmediatamente Logger::getInstance().flush(GetLogFileName("bugs")); }
void CLogActions::AddMsgLogLine(const char* szTargetLog,const char *szFormat, ...) { if(objSettings.SaveMesNotesByDef){ va_list vaList; va_start(vaList,szFormat); CString sBuffer; sBuffer.FormatV(szFormat,vaList); va_end (vaList); AddLogLine(GetLogFileName(DEFAULT_GENERALLOG), sBuffer, objSettings.dwMaxLogFileSize); if(objSettings.SaveMesNotesByDefForUser && strcmp(szTargetLog,DEFAULT_GENERALLOG)!=0){ AddLogLine(GetLogFileName(szTargetLog), sBuffer, objSettings.dwMaxLogFileSize); } } }
/********************************************************************* * 函数名称:int Write_Log_Text(LPLOG_DATA lpLogData) * 说明:写日志内容 * 调用者:Write_Log * 输入参数: * LPLOG_DATA lpLogData --日志内容结构体量 * 输出参数: * 无 * 返回值: * int -- LOG_FAILED: 失败 * -- LOG_SUCCESS: 成功 *********************************************************************/ int CWriteLog::Write_Log_Text(LPLOG_DATA lpLogData) { TCHAR szFilePath[MAX_FILE_PATH]; TCHAR szFileName[MAX_LOG_FILE_NAME_LEN]; FILE *pFile = NULL; TCHAR szLogText[MAX_LOGTEXT_LEN]; memset(szFilePath, 0, MAX_FILE_PATH); memset(szFileName, 0, MAX_LOG_FILE_NAME_LEN); memset(szLogText, 0, MAX_LOGTEXT_LEN); GetLogPath(szFilePath); GetLogFileName(lpLogData->iType, szFilePath, szFileName); pFile = _tfopen(szFileName, _T("a+")); if(NULL == pFile) { return LOG_FAILED; } _stprintf(szLogText, _T("%s[%s %s] %s ----- [%s][%d]\n"), lpLogData->strModel, lpLogData->strDate, lpLogData->strTime, lpLogData->strText, lpLogData->strFile, lpLogData->iLine); //fwrite(szLogText, 1, _tcslen(szLogText), pFile); //acsii 的方式, unicode写入乱码 int len = _tcslen(szLogText); char* pchBuffer = new char[len * 2 + 1]; int a = WideCharToMultiByte(CP_ACP, NULL, (LPCWCH)szLogText, -1, LPSTR(pchBuffer), len*2 + 1, NULL, FALSE);//Unicode转换为ANSI,a的值包括了字符串最后的0 fwrite(pchBuffer, 1, a - 1, pFile); delete[] pchBuffer; pchBuffer = NULL; fclose(pFile); return LOG_SUCCESS; }
void io::Log(string msg) { ofstream of_stream(GetLogFileName().c_str()); of_stream << msg; of_stream.close(); }
/** * @return true if operation was completed successfully. */ BOOL CLogStream::LoadEntries(void) { _ASSERTE(m_hFile == INVALID_HANDLE_VALUE); if (m_hFile != INVALID_HANDLE_VALUE) return FALSE; PCTSTR pszLogFileName = GetLogFileName(); m_hFile = CreateFile(pszLogFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (m_hFile == INVALID_HANDLE_VALUE) return FALSE; DWORD dwFileSize = GetFileSize(m_hFile, NULL); if (dwFileSize == 0) { DWORD dwWritten; if (! WriteFile(m_hFile, g_arrUTF8Preamble, sizeof(g_arrUTF8Preamble), &dwWritten, NULL)) goto error; } else { if (SetFilePointer(m_hFile, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER) goto error; } return TRUE; error: Close(); return FALSE; }
/// Log chosen policy void CvPolicyAI::LogPolicyChoice(PolicyTypes ePolicy) { if(GC.getLogging() && GC.getAILogging()) { CvString strOutBuf; CvString strBaseString; CvString strTemp; CvString playerName; CvString strDesc; // Find the name of this civ and city playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription(); FILogFile* pLog; pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp); // Get the leading info for this line strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns()); strBaseString += playerName + ", "; CvPolicyEntry* pPolicyEntry = GC.getPolicyInfo(ePolicy); const char* szPolicyType = (pPolicyEntry != NULL)? pPolicyEntry->GetType() : "Unknown"; strTemp.Format("CHOSEN, %s", szPolicyType); strOutBuf = strBaseString + strTemp; pLog->Msg(strOutBuf); } }
/** * @param bCrash - true if crash has occurred. * @return true if the log was saved successfully. */ BOOL CTextLogFile::SaveEntries(BOOL /*bCrash*/) { #ifdef _DEBUG DWORD dwStartTime = GetTickCount(); #endif PCTSTR pszLogFileName = GetLogFileName(); HANDLE hFile = CreateFile(pszLogFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return FALSE; DWORD dwWritten; WriteFile(hFile, g_arrUTF8Preamble, sizeof(g_arrUTF8Preamble), &dwWritten, NULL); CLogEntry* pLogEntry = GetFirstEntry(); while (pLogEntry) { CTextLogEntry* pTextLogEntry = (CTextLogEntry*)pLogEntry; WriteFile(hFile, pTextLogEntry->m_pbData, pTextLogEntry->m_dwSize, &dwWritten, NULL); pLogEntry = pLogEntry->m_pNextEntry; } #ifdef _DEBUG DWORD dwEndTime = GetTickCount(); TCHAR szMessage[128]; _stprintf_s(szMessage, countof(szMessage), _T("CTextLogFile::SaveEntries(): %lu entries, %lu bytes, %lu milliseconds\r\n"), GetNumEntries(), GetNumBytes(), dwEndTime - dwStartTime); OutputDebugString(szMessage); #endif CloseHandle(hFile); return TRUE; }
// line = "04:13:01.610|DEB| ogger\logger.c| 353| Log file created (05-09-2001)" void VEMiniLog::Print(int level, const char *pszModule, int iLineNumber, const char *pszFormat, ...) { // is tracing off? if(level > m_nTraceLevel) return; // error type const char *errType = level==-1 ? "SYS" : level==-2 ? "ERR" : "DEB"; // store time, module name & line number _strtime(gszParam); const char *pmod=strrchr(pszModule,'\\'); pmod=pmod!=0?pmod+1:pszModule; sprintf(&gszParam[strlen(gszParam)], ".000|%s|%-13s|%04d|",errType, pmod, iLineNumber); // get ... parameters va_list arg_ptr; va_start( arg_ptr, pszFormat ); _vsnprintf( &gszParam[strlen(gszParam)], sizeof(gszParam)-strlen(gszParam), pszFormat, arg_ptr ); va_end( arg_ptr ); // write line of log FILE *fp=fopen(GetLogFileName(),"ab"); if(fp==0) return; fwrite(gszParam,strlen(gszParam),1,fp); fwrite(ENDOFLINE,strlen(ENDOFLINE),1,fp); fclose(fp); }
/// Log chosen policy void CvPolicyAI::LogBranchChoice(PolicyBranchTypes eBranch) { if(GC.getLogging() && GC.getAILogging()) { CvString strOutBuf; CvString strBaseString; CvString strTemp; CvString playerName; CvString strDesc; // Find the name of this civ and city playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription(); FILogFile* pLog; pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp); // Get the leading info for this line strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns()); strBaseString += playerName + ", "; strTemp.Format("CHOSEN, Branch %d", eBranch); strOutBuf = strBaseString + strTemp; pLog->Msg(strOutBuf); } }
/// Logging function to write out info on Ideology choices void CvPolicyAI::LogIdeologyChoice(CvString &decisionState, int iWeightFreedom, int iWeightAutocracy, int iWeightOrder) { if(GC.getLogging() && GC.getAILogging()) { CvString strOutBuf; CvString strBaseString; CvString strTemp; CvString playerName; // Find the name of this civ playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription(); FILogFile* pLog; pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp); // Get the leading info for this line strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns()); strBaseString += playerName + ", "; strTemp.Format("%s, Freedom: %d, Order: %d, Autocracy: %d", decisionState.c_str(), iWeightFreedom, iWeightOrder, iWeightAutocracy); strOutBuf = strBaseString + strTemp; pLog->Msg(strOutBuf); } }
/// Log all possible tech choices void CvTechAI::LogPossibleResearch() { if(GC.getLogging() && GC.getAILogging()) { CvString strOutBuf; CvString strBaseString; CvString strTemp; CvString playerName; CvString strDesc; // Find the name of this civ playerName = m_pCurrentTechs->GetPlayer()->getCivilizationShortDescription(); FILogFile* pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp); // Get the leading info for this line strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns()); strBaseString += playerName + ", "; // Dump out the weight of each Researchable Tech for(int iI = 0; iI < m_ResearchableTechs.size(); iI++) { TechTypes eTech = (TechTypes) m_ResearchableTechs.GetElement(iI); int iWeight = m_ResearchableTechs.GetWeight(iI); CvTechEntry* pTechEntry = GC.getTechInfo(eTech); const char* szTechType = (pTechEntry != NULL)? pTechEntry->GetType() : "Unknown Tech"; strTemp.Format("%s, %d", szTechType, iWeight); strOutBuf = strBaseString + strTemp; pLog->Msg(strOutBuf); } } }
void LogConnect(int UserIndex, bool Join) { std::stringstream f; f << vb6::Now() << " " << UserList[UserIndex].Name << " ha " << (Join ? "entrado al" : "salido del") << " juego. NumUsers:" << NumUsers << " UserIndex:" << UserIndex << std::endl; auto &L = Logger::getInstance(); auto logFile = GetLogFileName("connect"); L.log(logFile, f.str()); L.flush(logFile); }
void CLogActions::AddMailLogLine(const char *szFormat, ...) { va_list vaList; va_start(vaList,szFormat); CString sBuffer; sBuffer.FormatV(szFormat,vaList); va_end (vaList); AddLogLine(GetLogFileName(DEFAULT_ANTISPAMLOG), sBuffer, objSettings.dwMaxMailLogFileSize); }
//--------------------------------------------------------------------- void TConfiguration::SetLogFileName(const UnicodeString & Value) { if (GetLogFileName() != Value) { FPermanentLogFileName = Value; FLogFileName = Value; Changed(); } }
void LogNumUsers() { std::stringstream f; auto &L = Logger::getInstance(); auto logFile = GetLogFileName("numusers"); f << vb6::Now() << " " << NumUsers << std::endl; L.reset(logFile); L.log(logFile, f.str()); L.flush(logFile); }
void SaveLog(char *buf,UINT16 len) { char path[64] = {0}; FILE* fp = NULL; fp = fopen(GetLogFileName(),"a+b"); if(!fp) return ; fwrite(buf,1,len,fp); fclose(fp); return; }
/** * @brief Open logfile and file descriptor */ AriesFrontendLogger::AriesFrontendLogger() { logging_type = LOGGING_TYPE_DRAM_NVM; LOG_INFO("Log File Name :: %s", GetLogFileName().c_str()); // open log file and file descriptor // we open it in append + binary mode log_file = fopen(GetLogFileName().c_str(), "ab+"); if (log_file == NULL) { LOG_ERROR("LogFile is NULL"); } // also, get the descriptor log_file_fd = fileno(log_file); if (log_file_fd == -1) { LOG_ERROR("log_file_fd is -1"); } // allocate pool recovery_pool = new VarlenPool(BACKEND_TYPE_MM); }
// public bool LogFile::RollFile () { time_t now = 0; std::string file_name = std::move (GetLogFileName (name_, &now)); time_t start = now / kRollPerSeconds * kRollPerSeconds; if (now > last_roll_) { last_roll_ = now; last_flush_ = now; start_of_period_ = start; file_.reset (new LogFile::AppendFile (file_name)); return true; } return false; }
/** * @brief create NVM backed log pool */ WriteBehindFrontendLogger::WriteBehindFrontendLogger() { logging_type = LOGGING_TYPE_NVM_NVM; // open log file and file descriptor // we open it in append + binary mode log_file = fopen(GetLogFileName().c_str(), "ab+"); if (log_file == NULL) { LOG_ERROR("LogFile is NULL"); } // also, get the descriptor log_file_fd = fileno(log_file); if (log_file_fd == -1) { LOG_ERROR("log_file_fd is -1"); } }
HANDLE CLogFile::openLogFile() { int savedLastError = GetLastError(); HANDLE hFile = CreateFile(GetLogFileName(), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); // If the specified file exists before the function call and dwCreationDisposition is CREATE_ALWAYS or OPEN_ALWAYS, // a call to GetLastError returns ERROR_ALREADY_EXISTS // (even though the function has succeeded). // If the file does not exist before the call, GetLastError returns zero. if (INVALID_HANDLE_VALUE != hFile) { SetLastError(savedLastError); } return hFile; }
/// Log all possible policy choices void CvPolicyAI::LogPossiblePolicies() { if(GC.getLogging() && GC.getAILogging()) { CvString strOutBuf; CvString strBaseString; CvString strTemp; CvString playerName; CvString strDesc; // Find the name of this civ and city playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription(); FILogFile* pLog; pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp); // Get the leading info for this line strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns()); strBaseString += playerName + ", "; int iNumBranches = GC.getNumPolicyBranchInfos(); // Dump out the weight of each possible policy for(int iI = 0; iI < m_AdoptablePolicies.size(); iI++) { int iWeight = m_AdoptablePolicies.GetWeight(iI); if(m_AdoptablePolicies.GetElement(iI) < iNumBranches) { strTemp.Format("Branch %d, %d", m_AdoptablePolicies.GetElement(iI), iWeight); } else { PolicyTypes ePolicy = (PolicyTypes)(m_AdoptablePolicies.GetElement(iI) - iNumBranches); CvPolicyEntry* pPolicyEntry = GC.getPolicyInfo(ePolicy); const char* szPolicyType = (pPolicyEntry != NULL)? pPolicyEntry->GetType() : "Unknown"; strTemp.Format("%s, %d", szPolicyType, iWeight); } strOutBuf = strBaseString + strTemp; pLog->Msg(strOutBuf); } } }
void SaveLog_Hex(char *buf,UINT16 len) { char path[64] = {0}; char tmp[3] = {0}; FILE* fp = NULL; fp = fopen(GetLogFileName(),"a+b"); if(!fp) return ; for (int i=1; i<len+1; i++) { sprintf(tmp,"%02X ",buf[i-1]); fwrite(tmp,1,3,fp); if (i % 16 == 0) { fwrite("\r\n",1,2,fp); } } fwrite("\r\n",1,2,fp); fclose(fp); return; }
void CLogRequest::SaveToFile() { const char *currentFileName = GetLogFileName(); m.lock(); CFile backupData(currentFileName); if(backupData.GetSize() < kMaxFileSize) { if(!mHasDate) { boost::posix_time::ptime now = boost::posix_time::second_clock::universal_time(); std::string strDate("&date="); std::string date = boost::posix_time::to_simple_string(now); CleanString(date); strDate += date; mData += strDate; } backupData.WriteLine(mData); } backupData.Close(); m.unlock(); }
ANGLE_LIBTESTER_EXPORT bool deqp_libtester_init_platform(int argc, const char *argv[]) { try { #if (DE_OS != DE_OS_WIN32) // Set stdout to line-buffered mode (will be fully buffered by default if stdout is pipe). setvbuf(stdout, DE_NULL, _IOLBF, 4 * 1024); #endif g_platform = createPlatform(); if (!deSetRoundingMode(DE_ROUNDINGMODE_TO_NEAREST_EVEN)) { std::cout << "Failed to set floating point rounding mode." << std::endl; return false; } std::string deqpDataDir; if (!FindDataDir(&deqpDataDir)) { std::cout << "Failed to find dEQP data directory." << std::endl; return false; } g_cmdLine = new tcu::CommandLine(argc, argv); g_archive = new tcu::DirArchive(deqpDataDir.c_str()); g_log = new tcu::TestLog(GetLogFileName(deqpDataDir).c_str(), g_cmdLine->getLogFlags()); g_testCtx = new tcu::TestContext(*g_platform, *g_archive, *g_log, *g_cmdLine, DE_NULL); g_root = new tcu::TestPackageRoot(*g_testCtx, tcu::TestPackageRegistry::getSingleton()); g_executor = new tcu::RandomOrderExecutor(*g_root, *g_testCtx); } catch (const std::exception& e) { tcu::die("%s", e.what()); return false; } return true; }
void SessionServer::InitializeFileLogger() { time_t curTime = time(NULL); tm curTM; localtime_s(&curTM, &curTime); if (!m_logWriter) { std::string filePath = s_defaultLogBaseLocation; filePath += "SharingServiceLogs"; filePath += "\\"; BOOL dirResult = CreateDirectoryA(filePath.c_str(), NULL); if (dirResult || GetLastError() == ERROR_ALREADY_EXISTS) { // Either we succeeded in creating the directory or it already exists. std::string fileName = "SharingService_"; fileName += std::to_string(curTM.tm_year + 1900); fileName += std::to_string(curTM.tm_mon + 1); fileName += std::to_string(curTM.tm_mday); fileName += ".log"; std::string fullPath = filePath + GetLogFileName(curTM); m_logWriter = new FileLogWriter(); m_logWriter->AddTargetFile(fullPath); } } m_logger = new Logger(); m_logger->SetWriter(m_logWriter); std::string curTimeString = GetCurrentDateTimeString(curTM); LogInfo(" ** Logging Session Began at %s", curTimeString.c_str()); }