Log.h 787 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright: All Rights Reserved
  2. // Author: egametang@gmail.com (tanghai)
  3. #ifndef BASE_LOG_H
  4. #define BASE_LOG_H
  5. #include <string>
  6. #include <memory>
  7. #include <boost/log/trivial.hpp>
  8. #include <boost/log/sources/severity_logger.hpp>
  9. namespace Egametang {
  10. #define ELOG(level) BOOST_LOG_SEV(ELog::GetSLog(), level) << "[" << FileName(__FILE__) << ":" << __LINE__ << "] "
  11. std::string FileName(const char* s);
  12. enum SeverityLevel
  13. {
  14. INFO = 0,
  15. WARNING = 1,
  16. ERROR = 2,
  17. FATAL = 3,
  18. };
  19. class ELog: public boost::noncopyable
  20. {
  21. private:
  22. static bool isInit;
  23. static boost::log::sources::severity_logger<SeverityLevel> slog;
  24. public:
  25. static void Init(const char* fileName);
  26. static boost::log::sources::severity_logger<SeverityLevel>& GetSLog();
  27. };
  28. }
  29. #endif // BASE_LOG_H