Skip to content

Replace fprintf with qt_log across all library sources - #25

Open
Xydane wants to merge 1 commit into
ServeurpersoCom:masterfrom
Xydane:master
Open

Replace fprintf with qt_log across all library sources#25
Xydane wants to merge 1 commit into
ServeurpersoCom:masterfrom
Xydane:master

Conversation

@Xydane

@Xydane Xydane commented Aug 12, 2026

Copy link
Copy Markdown

Replace fprintf with qt_log across all library sources

What changed

All fprintf(stderr, ...) call sites in the src/ library have been replaced
with qt_log(QT_LOG_xxx, ...) across 27 header files.

Headers that did not yet include qt-error.h gained the include; the
now-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 stderr unconditionally. With this
change, a single qt_log_set(cb, user_data) call redirects everything --
Python logging, Rust tracing, Android logcat, or any other sink.

Severity mapping

Level Used for
QT_LOG_ERROR FATAL / OOM / file I/O / graph compute failures
QT_LOG_WARN Recoverable surprises (missing optional GGUF keys, unknown tokens, unsupported-but-fallback paths)
QT_LOG_INFO Normal load and synthesis cadence (model loaded, N layers, weights MB, samples written, etc.)
QT_LOG_DEBUG Tensor dump shape lines and GGML dedup notices

Intentional exclusions

  • The single std::fprintf inside qt_log's own stderr fallback path (qwen.cpp) is 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant