Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*!
  2. * \file include/Log.h
  3. * \brief Log
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _LOG_H_
  8. #define _LOG_H_
  9. #include <string>
  10. #include <sstream>
  11. #include <vector>
  12. class Log {
  13. public:
  14. const static char endl = '\n';
  15. ~Log();
  16. unsigned long size();
  17. std::string get(unsigned long i);
  18. template<typename T>
  19. Log& operator<< (const T t) {
  20. printBuffer << t;
  21. if (printBuffer.str().back() == endl) {
  22. mHistory.push_back(printBuffer.str().substr(0, printBuffer.str().length() - 1));
  23. #ifdef DEBUG
  24. std::cout << printBuffer.str().substr(0, printBuffer.str().length() - 1) << std::endl;
  25. #endif
  26. printBuffer.str("");
  27. }
  28. return (*this);
  29. }
  30. private:
  31. std::vector<std::string> mHistory;
  32. std::ostringstream printBuffer;
  33. };
  34. Log &getLog();
  35. #endif