// Log.h: interface for the CLog class. // ////////////////////////////////////////////////////////////////////// //日志生成类 #if !defined(AFX_LOG_H__AAF3D405_307B_4E82_897B_1B2DA3810F1B__INCLUDED_) #define AFX_LOG_H__AAF3D405_307B_4E82_897B_1B2DA3810F1B__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "BaseUtility.h" #include "Instance.h" class CLog : public Instance { enum enmLogLevel{ LogLvlFatal = 0, LogLvlFailed, LogLvlError, LogLvlWarnning, LogLvlInfo, LogLvlTrace, LogLvlDebug, LogLvlAll }; friend class Instance; private: CLog(); public: ~CLog(); public: void SetMinLevel(UINT nLevel){m_nMinLevel=nLevel;}; void Put(const wchar_t* pszMsg, UINT nLevel = LogLvlFatal); void Put(char* pszMsg, UINT nLevel = LogLvlFatal); void PutMsg(const char *szFmt, ...); void PutMsg(const wchar_t * szFmt, ...); BOOL Init(const char* pszFileName,UINT nMinLevel,UINT nMaxSizeMB=10); protected: UINT m_nMinLevel; UINT m_nMaxLogSize; #ifdef _LOGCONSOLE CThreadPrintLog _loger; #else typedef struct __tagLogIndex{ DWORD dwPos; DWORD dwLen; BYTE nLevel; __tagLogIndex():dwPos(0L),dwLen(0L),nLevel(LogLvlAll) { }; }LOGINDEX; HANDLE m_hFile; LOGINDEX m_idx; char m_chFileName[260]; CRITICAL_SECTION m_cs; #endif // _DEBUG }; #endif // !defined(AFX_LOG_H__AAF3D405_307B_4E82_897B_1B2DA3810F1B__INCLUDED_)