/TGame/TUtil/Log/LogUtil.h

http://awoe.googlecode.com/ · C Header · 61 lines · 41 code · 17 blank · 3 comment · 0 complexity · f43a112803fa4c0a77b67e78cd6fb330 MD5 · raw file

  1. #ifndef __LOG_UTILES___
  2. #define __LOG_UTILES___
  3. #include <string>
  4. namespace woe
  5. {
  6. #ifdef UNICODE
  7. #define TS(str) L##str
  8. #else
  9. #define TS(str) str
  10. #endif
  11. enum
  12. {
  13. LGT_Simple,
  14. LGT_ThreadSafe,
  15. LGT_Async,
  16. };
  17. class TimeStamp
  18. {
  19. public:
  20. TimeStamp();
  21. TimeStamp(unsigned int seconds, unsigned int microSeconds = 0);
  22. inline int getSeconds() const { return _seconds; };
  23. inline int getMilliSeconds() const { return _microSeconds / 1000; };
  24. inline int getMicroSeconds() const { return _microSeconds; };
  25. void format(std::string& fmt)const;
  26. static inline const TimeStamp& getStartTime() { return _startStamp; };
  27. protected:
  28. static TimeStamp _startStamp;
  29. int _seconds;
  30. int _microSeconds;
  31. };
  32. class LogLevelUtil
  33. {
  34. public:
  35. //
  36. // get log level name
  37. //
  38. static const std::string& getLogLevelName(short lvl);
  39. static short getLogLevel(const std::string& lvlName);
  40. protected:
  41. static std::vector<std::string> __log_level_names;
  42. };
  43. }
  44. #endif