Polyphase Game Engine
Loading...
Searching...
No Matches
DebugLogWindow.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
6#include <string>
7#include <deque>
8#include <vector>
9#include <set>
10#include <mutex>
11
12struct DebugLogEntry
13{
14 LogSeverity mSeverity;
15 std::string mMessage;
16 float mTimestamp; // seconds since engine start
17 uint64_t mSeq = 0; // monotonic sequence number; 0 = unassigned
18};
19
20class DebugLogWindow
21{
22public:
23 void Draw();
24 void DrawContent();
25 void Clear();
26 static void LogCallback(LogSeverity severity, const char* message);
27
28 // Snapshot recent entries for external consumers (e.g. REST controller).
29 // Returns entries with seq > sinceSeq, up to maxCount. outNextSeq receives
30 // the latest sequence number produced so far (use it as the next sinceSeq).
31 // Must be called from the main thread.
32 void GetEntriesSnapshot(uint64_t sinceSeq,
33 uint32_t maxCount,
34 std::vector<DebugLogEntry>& outEntries,
35 uint64_t& outNextSeq);
36
37 bool mShowDebug = true;
38 bool mShowWarnings = true;
39 bool mShowErrors = true;
40 bool mAutoScroll = true;
41
42private:
43 std::deque<DebugLogEntry> mEntries;
44 std::deque<DebugLogEntry> mPendingEntries;
45 std::mutex mBufferMutex;
46 uint64_t mNextSeq = 0; // last assigned seq; guarded by mBufferMutex
47 static const size_t kMaxEntries = 2048;
48
49 char mSearchBuffer[256] = {};
50 bool mSearchActive = false;
51 std::vector<int> mSearchMatches;
52 int mCurrentMatchIndex = -1;
53 bool mNeedScrollToMatch = false;
54
55 std::set<int> mSelectedEntries;
56 int mLastClickedRow = -1;
57
58 void DrainPendingEntries();
59 void CopyAllToClipboard();
60 void CopySelectedToClipboard();
61 void UpdateSearchMatches();
62 void GoToNextMatch();
63 void GoToPrevMatch();
64};
65
66DebugLogWindow* GetDebugLogWindow();
67
68#endif
LogSeverity
Definition SystemTypes.h:139