CmDebug.h 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include "CmPrerequisitesUtil.h"
  3. #include "CmLog.h"
  4. namespace CamelotEngine
  5. {
  6. class Log;
  7. class CM_UTILITY_EXPORT Debug
  8. {
  9. public:
  10. void logDebug(std::string msg);
  11. void logInfo(std::string msg);
  12. void logWarning(std::string msg);
  13. void logError(std::string msg);
  14. void log(const String& msg, const String& channel);
  15. Log& getLog() { return mLog; }
  16. void writeAsBMP(const PixelData& pixelData, const String& filePath, bool overwrite = true) const;
  17. private:
  18. Log mLog;
  19. };
  20. CM_UTILITY_EXPORT Debug& gDebug();
  21. template <typename T>
  22. std::string toStr(T number)
  23. {
  24. std::ostringstream ss;
  25. ss << number;
  26. return ss.str();
  27. }
  28. #define LOGDBG(x) CamelotEngine::gDebug().logDebug((x));
  29. #define LOGINFO(x) CamelotEngine::gDebug().logInfo((x));
  30. #define LOGWRN(x) CamelotEngine::gDebug().logWarning((x));
  31. #define LOGERR(x) CamelotEngine::gDebug().logError((x));
  32. #define CM_ASSERT(x) assert(x)
  33. }