//构造函数 Logger::Logger(const char * strLogPath, EnumLogLevel nLogLevel):m_nLogLevel(nLogLevel) { //初始化 m_pFileStream = NULL; strcpy(m_strLogPath, strLogPath); InitializeCriticalSection(&m_cs); CreateLogPath(); GenerateLogName(); }
//构造函数 void Logger::init(const char * strLogPath, EnumLogLevel nLogLevel) { //初始化 //初始化 memset(m_strLogPath, 0, MAX_STR_LEN); memset(m_strCurLogName, 0, MAX_STR_LEN); m_nLogLevel=nLogLevel; m_pFileStream = NULL; strcpy_s(m_strLogPath, strLogPath); InitializeCriticalSection(&m_cs); CreateLogPath(); GenerateLogName(); }
void KJxUpdaterDlg::CheckUpdate() { int nRetCode = false; int nResult = false; ::GetCurrentDirectory(MAX_PATH, m_szAppPath); _sntprintf(m_szUpdatePath, MAX_PATH, "%s%s%s", m_szAppPath, CONFIG_PATH, "\\"); nRetCode = CreateLogPath(m_szUpdatePath); KG_PROCESS_ERROR(nRetCode); nRetCode = ClearFile(m_szUpdatePath); KG_PROCESS_ERROR(nRetCode); InitParam(); // nRetCode = LoadConfig(); // KG_PROCESS_ERROR(nRetCode); // nRetCode = CheckVersion(); // KG_PROCESS_ERROR(nRetCode); if (m_bNeedUpdate) { nRetCode = Update(); KG_PROCESS_ERROR(nRetCode); m_CtrlStatus.SetWindowText(MSG_SUCCESS); } else { //m_CtrlStatus.SetWindowText(MSG_ISNEW); //OnBnClickedQuit(); EndDialog(TRUE); } nResult = true; Exit0: if (!nResult) m_CtrlStatus.SetWindowText(MSG_ERROR); return; }
BOOL CTraceLog::OpenLog(SYSTEMTIME *pxt) { CHAR FileName[MAX_PATH] = {0}; if(CreateLogPath()==FALSE) return FALSE; //YYYYMMDD_hhmmss_uuu _snprintf(FileName, MAX_PATH, "%s\%04d%02d%02d_%02d%02d%02d.txt", m_szLogPath, pxt->wYear, pxt->wMonth, pxt->wDay, pxt->wHour, pxt->wMinute, pxt->wSecond); m_fstream.open(FileName, ios::out|ios::app|ios::binary); if(!m_fstream.is_open()){ printf("Create log file: %s fail.\n", FileName); return FALSE; } _snprintf(m_szCurLogName, MAX_PATH, FileName); m_wCurDay = pxt->wDay; m_lLineCounts = 0; return TRUE; }