Repository navigation
feat: expose C API logging callback (audiocpp_log_set) - #1235
Merged
Merged
Conversation
Owner
|
@kikaitachi Thanks for the PR! Two minor issues: (1) GGML errors reach the custom callback as DEBUG messages. You can reproduce this through the C API by registering a log callback and loading an invalid GGUF. (2) The API documentation overpromises: it says both engine and GGML logs are redirected, but only GGML logging is wired up. |
Contributor
Author
|
@0xShug0 Thank you for catching both of these!
|
Owner
|
@kikaitachi PR merged. Thanks! |
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.
Rationale
When embedding
libaudiocppin-process via the C ABI, underlying compute and backend libraries (such as GGML) write log, status, and debug messages directly tostderrby default using internal fallback callbacks.In host applications that embed
libaudiocppalongside their own logging frameworks (e.g. Quill, spdlog, Android logcat, or GUI/service sinks), these unformattedstderrwrites cannot be intercepted, redirected, formatted, or filtered by log level.This PR adds an explicit logging callback API (
audiocpp_log_set) modeled after the established pattern inllama.cpp(llama_log_set). It allows embedding applications to register a custom log handler with arbitraryuser_data, or passNULLto restore the defaultstderrbehavior.Changes
include/audiocpp.h:AUDIOCPP_ABI_VERSION_MINORfrom2to3.audiocpp_log_levelenum (NONE,INFO,WARN,ERROR,DEBUG,CONT).audiocpp_log_callbacktypedef.audiocpp_log_set(audiocpp_log_callback log_callback, void * user_data).src/capi/audiocpp.cpp:audiocpp_log_setwith thread-safe callback state forwarding toggml_log_set.tests/capi/path_test.c:audiocpp_log_set.docs/c_api.md:## Loggingusage documentation and ABI version check example for0.3.Validation
Tested on Linux
aarch64:audiocpp_c_api_exports: Passed (exact match of declared symbols, 0 leaked).audiocpp_c_api_path: Passed (asserts ABI contract and log callback registration/reset).AI usage disclosure
Generated by Gemini Flash 3.8 Medium.