Replace fprintf with qt_log across all library sources - #25
Open
Xydane wants to merge 1 commit into
Open
Conversation
Eliminate all fprintf(stderr, ...) call sites from the src/ library
headers and replace them with qt_log(QT_LOG_xxx, ...) so that every
diagnostic is routable through the user-installed qt_log_cb
(Python logging, Rust tracing, etc.) instead of being hard-wired to
stderr.
Severity mapping:
QT_LOG_ERROR - FATAL / OOM / file I/O / graph compute failures
QT_LOG_WARN - recoverable surprises (missing optional keys,
unknown tokens, unsupported-but-fallback paths)
QT_LOG_INFO - normal load and synthesis cadence messages
QT_LOG_DEBUG - tensor dump details (debug.h shape lines,
GGML dedup log lines in backend.h)
Headers that did not yet include qt-error.h gained the include;
the now-redundant #include <cstdio> was removed from each of those
files. The single std::fprintf inside qt_log's own stderr fallback
path (qwen.cpp) is intentionally untouched - it is the fallback
implementation itself. The tools/ CLI executables are out of scope;
their fprintf output is direct terminal UX, not library diagnostics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace
fprintfwithqt_logacross all library sourcesWhat changed
All
fprintf(stderr, ...)call sites in thesrc/library have been replacedwith
qt_log(QT_LOG_xxx, ...)across 27 header files.Headers that did not yet include
qt-error.hgained the include; thenow-redundant
#include <cstdio>was removed from each of those files.Why it was needed
Previously, wrapping the library in a higher-level binding meant that load
progress, warnings, and fatal errors would bypass whatever logging framework
the host application used and land on
stderrunconditionally. With thischange, a single
qt_log_set(cb, user_data)call redirects everything --Python
logging, Rusttracing, Android logcat, or any other sink.Severity mapping
QT_LOG_ERRORFATAL/ OOM / file I/O / graph compute failuresQT_LOG_WARNQT_LOG_INFOQT_LOG_DEBUGIntentional exclusions
std::fprintfinsideqt_log's own stderr fallback path (qwen.cpp) is untouched -- it is the fallback implementation itself.tools/CLI executables are out of scope; theirfprintfoutput is direct terminal UX, not library diagnostics.