Skip to content

Wrap global logging hooks (whisper_set_log_callback) #16

@uqio

Description

@uqio

Tracked under #6.

Scope

Provide a Rust-side hook to redirect whisper.cpp's diagnostic output (currently eprintln!-shaped) into log / tracing or a custom sink.

Symbols

  • whisper_set_log_callback, whisper_log_callback.
  • set_debug_mode (per-context flag, separate but related).

Why deferred

whisper_set_log_callback is a global hook — registers across all instances in the process. Mixing it with Rust logging frameworks (log, tracing) needs more design than a 1:1 port:

  • Process-wide registration is hostile to libraries that want to ship an Arc<dyn Subscriber>-style integration.
  • The C callback runs on whichever thread emitted the log; the Rust side has to be Sync.
  • Initialising the hook before any whisper.cpp call requires either an OnceCell or a constructor hook, both of which introduce ordering concerns.

Whispery routes its own diagnostics through eprintln! / tracing already, so it doesn't need this.

Acceptance

Open design questions to resolve before implementation:

  1. Process-wide singleton (whispercpp::set_log_handler(impl Fn(...))) vs per-Context hook? Upstream is process-wide.
  2. Auto-bridge to log crate (a whispercpp = { version = "...", features = ["log"] } feature gate)?
  3. Auto-bridge to tracing (separate feature)?
  4. Behaviour for callers who never set a handler — eprintln! (current upstream default) or silent?

Probably wants an RFC-style design issue / PR before implementation.

If you have a logging integration story you'd want to support, drop a comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions