51 lines
1.9 KiB
C++
51 lines
1.9 KiB
C++
#pragma once
|
|
|
|
|
|
#ifdef _DEBUG
|
|
#pragma comment(lib, "./Uitl/log4cxx0.10.0/lib_2005/log4cxxd.lib")
|
|
#else
|
|
#pragma comment(lib, "./Uitl/log4cxx0.10.0/lib_2005/log4cxx.lib")
|
|
#endif
|
|
|
|
#define LOGBUFFER_SIZE 8192
|
|
|
|
#include <log4cxx/logger.h>
|
|
#include <log4cxx/dailyrollingfileappender.h>
|
|
#include <log4cxx/consoleappender.h>
|
|
#include <log4cxx/patternlayout.h>
|
|
#include <log4cxx/helpers/transcoder.h>
|
|
#include "criticalsection.h"
|
|
|
|
using namespace log4cxx;
|
|
using namespace log4cxx::helpers;
|
|
|
|
#define BILLING_LOG _instance(WZPUBLIC::CLog)->WriteLog
|
|
#define BILLING_OTHER_LOG _instance(WZPUBLIC::CLog)->WriteOtherLog
|
|
|
|
#define BILLING_LOG_FATAL(_msg) LOG4CXX_FATAL(WZPUBLIC::CSingleton<WZPUBLIC::CLog>::GetInstance()->GetLogPtr(), _msg);
|
|
#define BILLING_LOG_ERROR(_msg) LOG4CXX_ERROR(WZPUBLIC::CSingleton<WZPUBLIC::CLog>::GetInstance()->GetLogPtr(), _msg);
|
|
#define BILLING_LOG_WARN(_msg) LOG4CXX_WARN(WZPUBLIC::CSingleton<WZPUBLIC::CLog>::GetInstance()->GetLogPtr(), _msg);
|
|
#define BILLING_LOG_INFO(_msg) LOG4CXX_INFO(WZPUBLIC::CSingleton<WZPUBLIC::CLog>::GetInstance()->GetLogPtr(), _msg);
|
|
#define BILLING_LOG_DEBUG(_msg) LOG4CXX_DEBUG(WZPUBLIC::CSingleton<WZPUBLIC::CLog>::GetInstance()->GetLogPtr(), _msg);
|
|
#define BILLING_LOG_TRACE(_msg) LOG4CXX_TRACE(WZPUBLIC::CSingleton<WZPUBLIC::CLog>::GetInstance()->GetLogPtr(), _msg);
|
|
|
|
namespace WZPUBLIC
|
|
{
|
|
enum LOG_LEVEL {LEVEL_ALL, LEVEL_FATAL, LEVEL_ERROR, LEVEL_WARN, LEVEL_INFO, LEVEL_DEBUG, LEVEL_TRACE, LEVEL_OFF};
|
|
class CLog
|
|
{
|
|
public:
|
|
CLog();
|
|
virtual ~CLog();
|
|
|
|
void CreateLog(wchar_t* szFilePath, bool bconsole);
|
|
void SetLogfilePath(wchar_t* szFilePath, bool bconsole);
|
|
void SetLevel(LOG_LEVEL level);
|
|
LoggerPtr GetLogPtr() {return m_rootLogger;};
|
|
void WriteLog(LOG_LEVEL level, const char* szFormat, ...);
|
|
void WriteOtherLog(char* szFilePath, const char* szFormat, ...);
|
|
private:
|
|
LoggerPtr m_rootLogger;
|
|
WZPUBLIC::CriticalSection m_csOtherLog;
|
|
};
|
|
}; |