fix: improve error context with unified logging and error return traces (#276) - #318
Conversation
…es (#276) Add errWithTrace() to log.zig for automatic stack trace dumps at error sites. Migrate all 139 std.log.* calls to the custom logger across 27 files for consistent formatting. Add errWithTrace to 30+ critical catch sites (mesh build, GPU recovery, resource recreation, shader loading). Add contextual init logging to App, World, and RenderSystem startup. Fix missing errdefer in World.initGen() that leaked the streamer on renderer init failure.
|
Now I have all the information needed for a comprehensive review. 📋 SummaryThis PR Closes #276 - Improving error context with unified logging and error return traces. Purpose: Standardizes all logging through a custom Scope: 35 files changed, 204 insertions(+), 148 deletions(-). All 139 Overall Quality: Good - The PR successfully addresses all acceptance criteria from #276. Tests pass, the code follows Zig conventions, and the changes improve observability without adding runtime overhead in release builds. 🔴 Critical Issues (Must Fix - Blocks Merge)None identified.
|
| Principle | Score | Notes |
|---|---|---|
| Single Responsibility | 9 | log.zig has single responsibility for logging; migration doesn't mix concerns |
| Open/Closed | 8 | Logger is extensible via LogLevel enum; new levels can be added without modifying consumers |
| Liskov Substitution | 10 | No inheritance hierarchies affected; pure struct-based design |
| Interface Segregation | 9 | Logger provides focused API (trace/debug/info/warn/err/errWithTrace/fatal) |
| Dependency Inversion | 8 | All modules now depend on log.zig abstraction instead of std.log directly |
| Average | 8.8 | Strong adherence to SOLID principles |
🎯 Final Assessment
Overall Confidence Score: 92%
How to interpret:
- 0-30%: Major concerns, do not merge without significant rework
- 31-60%: Moderate concerns, several issues need addressing
- 61-80%: Minor concerns, mostly ready with some fixes
- 81-100%: High confidence, ready to merge or with trivial fixes
Confidence Breakdown:
- Code Quality: 95% (Clean implementation following Zig idioms, consistent patterns)
- Completeness: 90% (All acceptance criteria from [MED] Improve error context - Add file:line information and descriptive error messages #276 met, tests pass)
- Risk Level: 90% (Low risk - logging changes are additive, errdefer fix is correct)
- Test Coverage: 95% (All existing tests pass, shader validation included)
Merge Readiness:
- All critical issues resolved
- SOLID average score >= 6.0
- Overall confidence >= 60%
- No security concerns
- Tests present and passing (if applicable)
Verdict:
MERGE
This PR successfully implements comprehensive error logging improvements, unifies 139 logging calls across 27 files, adds contextual stack traces at 30+ error sites, and fixes a resource leak bug. All tests pass and the code follows project conventions.

Summary
Closes #276
log.zig: AddederrWithTrace()method that logs an error and automatically dumps the error return trace stack via@errorReturnTrace(), giving full stack traces at error sitesstd.log.*calls across 27 files to the customlog.log.*logger for consistent formatting and a single source of trutherrWithTrace()in mesh building, GPU recovery, resource recreation, shader loading, and moreApp.init(),World.initGen(), andRenderSystem.init()errdeferinWorld.initGen()that leaked the WorldStreamer if WorldRenderer init failedChanges
src/engine/core/log.zigerrWithTrace()method for error logging with automatic stack trace dumpsLogging Migration (27 files, 139 call sites)
src/world/*.zig(6 files): world.zig, chunk_mesh.zig, chunk_allocator.zig, world_renderer.zig, world_streamer.zig, lod_upload_queue.zig, registry.zigsrc/engine/graphics/*.zig+vulkan/*.zig(17 files): rhi_vulkan.zig, vulkan_device.zig, lpv_system.zig, and all vulkan/ sub-modulessrc/game/*.zig(4 files): session.zig, settings/persistence.zig, settings/json_presets.zigError Return Trace Sites (30+ locations)
Init Context Logging
App.init(): logs before SettingsManager, WindowManager, RenderSystem, AudioSystemManager, UISystemManagerWorld.initGen(): logs before WorldStreamer and WorldRenderer initRenderSystem.init(): logs before RHI device init, resource packs, texture atlas, AtmosphereSystem, MaterialSystem, LPVSystemAcceptance Criteria (from #276)
@errorReturnTrace())errWithTrace())