debug.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef AL_DEBUG_H
  2. #define AL_DEBUG_H
  3. #include <cstdint>
  4. #include <string>
  5. #include <utility>
  6. #include <vector>
  7. using uint = unsigned int;
  8. /* Somewhat arbitrary. Avoid letting it get out of control if the app enables
  9. * logging but never reads it.
  10. */
  11. inline constexpr std::uint8_t MaxDebugLoggedMessages{64};
  12. inline constexpr std::uint16_t MaxDebugMessageLength{1024};
  13. inline constexpr std::uint8_t MaxDebugGroupDepth{64};
  14. inline constexpr std::uint16_t MaxObjectLabelLength{1024};
  15. inline constexpr uint DebugSourceBase{0};
  16. enum class DebugSource : std::uint8_t {
  17. API = 0,
  18. System,
  19. ThirdParty,
  20. Application,
  21. Other,
  22. };
  23. inline constexpr uint DebugSourceCount{5};
  24. inline constexpr uint DebugTypeBase{DebugSourceBase + DebugSourceCount};
  25. enum class DebugType : std::uint8_t {
  26. Error = 0,
  27. DeprecatedBehavior,
  28. UndefinedBehavior,
  29. Portability,
  30. Performance,
  31. Marker,
  32. PushGroup,
  33. PopGroup,
  34. Other,
  35. };
  36. inline constexpr uint DebugTypeCount{9};
  37. inline constexpr uint DebugSeverityBase{DebugTypeBase + DebugTypeCount};
  38. enum class DebugSeverity : std::uint8_t {
  39. High = 0,
  40. Medium,
  41. Low,
  42. Notification,
  43. };
  44. inline constexpr uint DebugSeverityCount{4};
  45. struct DebugGroup {
  46. const uint mId;
  47. const DebugSource mSource;
  48. std::string mMessage;
  49. std::vector<uint> mFilters;
  50. std::vector<std::uint64_t> mIdFilters;
  51. template<typename T>
  52. DebugGroup(DebugSource source, uint id, T&& message)
  53. : mId{id}, mSource{source}, mMessage{std::forward<T>(message)}
  54. { }
  55. DebugGroup(const DebugGroup&) = default;
  56. DebugGroup(DebugGroup&&) = default;
  57. ~DebugGroup();
  58. };
  59. #endif /* AL_DEBUG_H */