aboutsummaryrefslogtreecommitdiffstats
path: root/al/debug.h
blob: 2764bb7f794ad1f07aaa4ff7665119dee422f172 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef AL_DEBUG_H
#define AL_DEBUG_H

#include <stdint.h>
#include <string>
#include <vector>

using uint = unsigned int;


/* Somewhat arbitrary. Avoid letting it get out of control if the app enables
 * logging but never reads it.
 */
inline constexpr uint8_t MaxDebugLoggedMessages{64};
inline constexpr uint16_t MaxDebugMessageLength{1024};
inline constexpr uint8_t MaxDebugGroupDepth{64};
inline constexpr uint16_t MaxObjectLabelLength{1024};


inline constexpr uint DebugSourceBase{0};
enum class DebugSource : uint8_t {
    API = 0,
    System,
    ThirdParty,
    Application,
    Other,
};
inline constexpr uint DebugSourceCount{5};

inline constexpr uint DebugTypeBase{DebugSourceBase + DebugSourceCount};
enum class DebugType : uint8_t {
    Error = 0,
    DeprecatedBehavior,
    UndefinedBehavior,
    Portability,
    Performance,
    Marker,
    PushGroup,
    PopGroup,
    Other,
};
inline constexpr uint DebugTypeCount{9};

inline constexpr uint DebugSeverityBase{DebugTypeBase + DebugTypeCount};
enum class DebugSeverity : uint8_t {
    High = 0,
    Medium,
    Low,
    Notification,
};
inline constexpr uint DebugSeverityCount{4};

struct DebugGroup {
    const uint mId;
    const DebugSource mSource;
    std::string mMessage;
    std::vector<uint> mFilters;
    std::vector<uint64_t> mIdFilters;

    template<typename T>
    DebugGroup(DebugSource source, uint id, T&& message)
        : mId{id}, mSource{source}, mMessage{std::forward<T>(message)}
    { }
    DebugGroup(const DebugGroup&) = default;
    DebugGroup(DebugGroup&&) = default;
};

#endif /* AL_DEBUG_H */