CmDebug.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include "CmPrerequisitesUtil.h"
  3. #include "CmLog.h"
  4. namespace CamelotFramework
  5. {
  6. class Log;
  7. /**
  8. * @brief Utility class providing various debug functionality. Thread safe.
  9. */
  10. class CM_UTILITY_EXPORT Debug
  11. {
  12. public:
  13. /**
  14. * @brief Adds a log entry in the "Debug" channel.
  15. */
  16. void logDebug(const String& msg);
  17. /**
  18. * @brief Adds a log entry in the "Info" channel.
  19. */
  20. void logInfo(const String& msg);
  21. /**
  22. * @brief Adds a log entry in the "Warning" channel.
  23. */
  24. void logWarning(const String& msg);
  25. /**
  26. * @brief Adds a log entry in the "Error" channel.
  27. */
  28. void logError(const String& msg);
  29. /**
  30. * @brief Adds a log entry in the specified channel. You may specify custom channels as needed.
  31. */
  32. void log(const String& msg, const String& channel);
  33. /**
  34. * @brief Retrieves the Log used by the Debug instance.
  35. */
  36. Log& getLog() { return mLog; }
  37. /**
  38. * @brief Converts raw pixels into a BMP image. See "BitmapWriter" for more information.
  39. */
  40. void writeAsBMP(UINT8* rawPixels, UINT32 bytesPerPixel, UINT32 width, UINT32 height, const WString& filePath, bool overwrite = true) const;
  41. private:
  42. Log mLog;
  43. };
  44. CM_UTILITY_EXPORT Debug& gDebug();
  45. #define LOGDBG(x) CamelotFramework::gDebug().logDebug((x));
  46. #define LOGINFO(x) CamelotFramework::gDebug().logInfo((x));
  47. #define LOGWRN(x) CamelotFramework::gDebug().logWarning((x));
  48. #define LOGERR(x) CamelotFramework::gDebug().logError((x));
  49. #define CM_ASSERT(x) assert(x)
  50. }