My Project
|
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 #pragma once 00029 #include "Define.h" 00030 #include <string> 00031 #include <comdef.h> 00032 #include "DateHelper.h" 00033 00034 namespace SallyAPI 00035 { 00036 namespace System 00037 { 00043 00044 enum LOG_LEVEL {LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARNING, LOG_LEVEL_ERROR}; 00045 00054 00055 class DLL_API_SALLY CLogger 00056 { 00057 private: 00058 std::string m_strFilename; 00059 HANDLE m_hFile; 00060 LOG_LEVEL m_eLogLevel; 00061 00062 CRITICAL_SECTION m_critSectLock; 00063 protected: 00064 virtual void WriteLog(const std::string& s); 00065 public: 00066 CLogger(const std::string& fileName, bool createNew = true, LOG_LEVEL logLevel = LOG_LEVEL_INFO); 00067 virtual ~CLogger(); 00068 00069 void SetLogLevel(LOG_LEVEL logLevel); 00070 LOG_LEVEL GetLogLevel(); 00071 std::string GetFilename(); 00072 00073 void Debug(const std::string& s); 00074 void Error(const std::string& s); 00075 void Warning(const std::string& s); 00076 void Info(const std::string& s); 00077 00078 void Debug(int s); 00079 void Error(int s); 00080 void Warning(int s); 00081 void Info(int s); 00082 00083 void Debug(HRESULT s); 00084 void Error(HRESULT s); 00085 void Warning(HRESULT s); 00086 void Info(HRESULT s); 00087 }; 00088 } 00089 }