BsDebug.h 1.6 KB

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