Add game state debug log (binary ring buffer) #27

Merged
tas merged 1 commits from feature/debuglog into main 2026-03-16 20:34:37 +00:00
Collaborator

Implements the debug log module from issue 19. New src/engine/debuglog module with 4 MB in-memory ring buffer that records per-tick snapshots of input, player state, camera, physics, and entities. Activated via --debug-log CLI flag; F12 dumps to debug_log.txt. Auto-flushes every 10 seconds as crash safety net. Adds input_get_snapshot() and debuglog_set_level() registered-pointer pattern for engine/game boundary. Closes #19

Implements the debug log module from issue 19. New src/engine/debuglog module with 4 MB in-memory ring buffer that records per-tick snapshots of input, player state, camera, physics, and entities. Activated via --debug-log CLI flag; F12 dumps to debug_log.txt. Auto-flushes every 10 seconds as crash safety net. Adds input_get_snapshot() and debuglog_set_level() registered-pointer pattern for engine/game boundary. Closes #19
tas added 1 commit 2026-03-16 20:33:05 +00:00
Add game state debug log with binary ring buffer
All checks were successful
CI / build (pull_request) Successful in 32s
Deploy / deploy (push) Successful in 1m17s
3b45572d38
Implement src/engine/debuglog module that records a comprehensive
snapshot of game state every tick into a 4 MB in-memory ring buffer.

Activated by --debug-log command-line flag. Press F12 during gameplay
to dump the ring buffer to a human-readable debug_log.txt file. The
buffer also auto-flushes every 10 seconds as a safety net.

Each tick snapshot captures: input state (held/pressed/released bitmasks),
full player state (position, velocity, health, dash, aim, timers),
camera position, physics globals, level name, and a variable-length
list of all active entity positions/velocities/health.

New files:
- src/engine/debuglog.h — API and snapshot data structures
- src/engine/debuglog.c — ring buffer, record, and dump logic

Modified files:
- include/config.h — DEBUGLOG_BUFFER_SIZE constant
- src/engine/input.h/c — input_get_snapshot() to pack input bitmasks
- src/engine/core.c — debuglog_record_tick() call after update
- src/main.c — CLI flag, init/shutdown, F12 hotkey, set_level calls

Closes #19
tas force-pushed feature/debuglog from 34c77f7a1e to 3b45572d38 2026-03-16 20:33:05 +00:00 Compare
tas merged commit 3b45572d38 into main 2026-03-16 20:34:37 +00:00
tas deleted branch feature/debuglog 2026-03-16 20:34:38 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: tas/major_tom#27