1 #ifndef DOZERG_LOGGER_H_20130320 2 #define DOZERG_LOGGER_H_20130320 20 #include "impl/logger_impl.hh" 33 inline void LOGGER_SET_LEVEL(
const std::string & level)
35 NS_IMPL::CGlobalLogger::Instance().setLevel(level);
42 inline void LOGGER_SET_MAX_SIZE(
size_t maxSize)
44 NS_IMPL::CGlobalLogger::Instance().setMaxSize(maxSize);
48 inline void LOGGER_SET_MAX_NUMBER(
int maxNumber)
50 NS_IMPL::CGlobalLogger::Instance().setMaxNumber(maxNumber);
59 inline bool LOGGER_CRASH_HANDLER()
61 return NS_IMPL::CGlobalLogger::Instance().registerCrashHandler();
72 inline bool LOGGER_INIT(
const std::string & fname,
const std::string & level,
size_t maxSize,
int maxNumber)
74 LOGGER_SET_LEVEL(level);
75 LOGGER_SET_MAX_SIZE(maxSize);
76 LOGGER_SET_MAX_NUMBER(maxNumber);
77 return NS_IMPL::CGlobalLogger::Instance().init(fname);
82 #define LOGGER_LOG(level, msg, console) \ 84 const bool file = NS_SERVER::NS_IMPL::CGlobalLogger::Instance().shouldLog(level); \ 85 if(file || console){ \ 86 NS_SERVER::NS_IMPL::CLocalLogger logger(level, __FILE__, __LINE__, __FUNCTION__); \ 87 logger.oss()<<msg<<'\n'; \ 96 #define LOGGER_TRACE(msg) LOGGER_LOG(NS_SERVER::NS_IMPL::CGlobalLogger::kTrace, msg, false) 97 #define LOGGER_DEBUG(msg) LOGGER_LOG(NS_SERVER::NS_IMPL::CGlobalLogger::kDebug, msg, false) 98 #define LOGGER_INFO(msg) LOGGER_LOG(NS_SERVER::NS_IMPL::CGlobalLogger::kInfo, msg, false) 99 #define LOGGER_WARN(msg) LOGGER_LOG(NS_SERVER::NS_IMPL::CGlobalLogger::kWarn, msg, false) 100 #define LOGGER_ERROR(msg) LOGGER_LOG(NS_SERVER::NS_IMPL::CGlobalLogger::kError, msg, false) 101 #define LOGGER_FATAL(msg) LOGGER_LOG(NS_SERVER::NS_IMPL::CGlobalLogger::kFatal, msg, true) 105 # define LOGGER_ASSERT(expr, msg) do{if(!(expr)){LOGGER_FATAL("ASSERT(" #expr ") failed: "<<msg);::abort();}}while(0) 107 # define LOGGER_ASSERT(expr, msg) 113 # define TRACE LOGGER_TRACE 116 # define DEBUG LOGGER_DEBUG 119 # define INFO LOGGER_INFO 122 # define WARN LOGGER_WARN 125 # define ERROR LOGGER_ERROR 128 # define FATAL LOGGER_FATAL 131 # define ASSERT LOGGER_ASSERT