Repository navigation
fix(logging): send library logs to stderr and give failures a real se… - #781
Ayushrawatcy009 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
WalkthroughThe logger now writes to stderr. GPU initialization failures use WARN or ERROR, while setup progress and GPU processing-stage messages use DEBUG. GPU initialization and processing behavior remain unchanged. ChangesGPU logging
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to
|
…verity
Changes & Reason
Changes
log.h: the logger now usesspdlog::stderr_color_mtinstead of the stdout one.gpu.h: gave each log call the level from the table in the issue:[WEBGPU FATAL ERROR],[DEVICE LOST]Adapter Failed,Device Failedkmeans_gpu.cppandbilateral_filter_gpu.cpp: all the step tracing is now DEBUG instead of INFO.I didn't add any new log statements or touch what
IMG2NUM_LOG_LEVEL=AUTOresolves to. Release builds aren't affected since logging is compiled out there.Reason
The logger was writing to stdout, so any program that prints its result there (like piping an SVG into another command) got log lines mixed into the output. On top of that everything was INFO, so building with
IMG2NUM_LOG_LEVEL=WARNhid the real failures, and INFO was too noisy to keep on.Related Issues
Fixes: #727
Testing & Verification
just cmake build Debug, then ran the C++ console example with> out.txt 2> err.txt.out.txthad 0 log lines anderr.txthad all 35 (screenshot below).err.txtmatch the table: tracing and the limits lines are[debug], and only Adapter Acquired, Device Acquired and GPU Fully Initialized are[info].just cmake build Debug WARNprinted 0 log lines. My GPU works, so there were no fallbacks or errors to show, but all the INFO/DEBUG noise is gone.WASM build not tested. I don't have Emscripten installed, so I couldn't do the
just js build Debugcheck from the issue. Since Emscripten sends stderr toconsole.error, the logs might show up as errors in the browser console. If you see that, I can add the#ifdef __EMSCRIPTEN__fallback to stdout in this PR, or as a follow-up, whichever you prefer.Additional Resources
Debug build, stdout vs stderr:

WARN build:

Heads up: this touches lines near "No usable WebGPU adapter found" in
gpu.h, which the clang-format PR also touches, so whichever lands second needs a rebase.