BsDebug.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include "BsPrerequisitesUtil.h"
  3. #include "BsLog.h"
  4. namespace BansheeEngine
  5. {
  6. class Log;
  7. /**
  8. * @brief Utility class providing various debug functionality. Thread safe.
  9. */
  10. class BS_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 Path& filePath, bool overwrite = true) const;
  41. private:
  42. Log mLog;
  43. };
  44. BS_UTILITY_EXPORT Debug& gDebug();
  45. #define LOGDBG(x) BansheeEngine::gDebug().logDebug((x));
  46. #define LOGINFO(x) BansheeEngine::gDebug().logInfo((x));
  47. #define LOGWRN(x) BansheeEngine::gDebug().logWarning((x));
  48. #define LOGERR(x) BansheeEngine::gDebug().logError((x));
  49. }