#if !defined(LOGGER_H__5142BB38_5565_4124_88A4_56EA08298154__INCLUDED_) #define LOGGER_H__5142BB38_5565_4124_88A4_56EA08298154__INCLUDED_ #include #include #include #include #include #include #include const long LOGINIT = 0x0001; const long LOGACTIONS = 0x0002; const long LOGCOMM = 0x0004; const long LOGFLUSH = 0x0008; class CLogger { public: CLogger(CString m_Name) { IsEnabledLog = false; m_File = nullptr; CString Path = _T(""); // Speed optimization - noticed slow in GlowCode if (Path.IsEmpty()) { CString tmpPath; GetModuleFileName(nullptr, tmpPath.GetBuffer(255), 255); tmpPath.ReleaseBuffer(); tmpPath.TrimRight(); int nLastSlash = tmpPath.ReverseFind('\\'); if (nLastSlash >= 0) tmpPath = tmpPath.Left(nLastSlash); else tmpPath.Empty(); Path = tmpPath; } m_FileName = Path + m_Name; //_T("\\SO7_SSILog.txt"); m_lLogMask = 0; InitializeCriticalSection(&m_lockLogger); }; ~CLogger() { if (m_File) fclose(m_File); DeleteCriticalSection(&m_lockLogger); }; void SendAtTime(const TCHAR* buffer); void Send(LPCTSTR, ...); void SendAndFlush(LPCTSTR, ...); void SendAndFlushPerMode(LPCTSTR, ...); void SendAndFlushWithTime(LPCTSTR, ...); bool IsEnabledLog/* = false*/; //是否启用日志 CString m_FileName; long m_lLogMask; FILE* m_File; _TCHAR m_Str[20000]; _TCHAR m_Str2[20000]; CRITICAL_SECTION m_lockLogger; }; #endif // !defined(LOGGER_H__5142BB38_5565_4124_88A4_56EA08298154__INCLUDED_)