Log.h 745 B

12345678910111213141516171819202122232425262728293031
  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 <boost/shared_ptr.hpp>
  7. #include <boost/log/trivial.hpp>
  8. #include <boost/filesystem.hpp>
  9. #include <boost/log/sinks/sync_frontend.hpp>
  10. #include <boost/log/sinks/text_ostream_backend.hpp>
  11. namespace Egametang {
  12. #define ELOG(level) BOOST_LOG_TRIVIAL(level) << "[" << FileName(__FILE__) << ":" << __LINE__ << "] "
  13. std::string FileName(const char* s);
  14. class BoostLogInit
  15. {
  16. private:
  17. typedef boost::log::sinks::synchronous_sink<boost::log::sinks::text_ostream_backend> text_sink;
  18. boost::shared_ptr<text_sink> pSink;
  19. public:
  20. BoostLogInit(const char* fileName);
  21. ~BoostLogInit();
  22. };
  23. }
  24. #endif // BASE_LOG_H