Skip to content

Forward Rust logs through FFI to SDK logger#133

Open
alan-george-lk wants to merge 19 commits into
mainfrom
feature/forward_rust_logs
Open

Forward Rust logs through FFI to SDK logger#133
alan-george-lk wants to merge 19 commits into
mainfrom
feature/forward_rust_logs

Conversation

@alan-george-lk
Copy link
Copy Markdown
Collaborator

@alan-george-lk alan-george-lk commented May 18, 2026

This PR does the following:

  • Forwards all Rust logs via FFI log event (forwards any log macro invocation from Rust code)
    • Critical note: livekit::initialize(level, log_sink) is deprecated as of this PR but is still backwards compatible. log_sink did not accurately change logging behavior, and livekit::setLogCallback is actually the only way. The FFI log API change is independent of callback behavior, but this PR also ensures logs from SDK or FFI layer work the same sink-wise. Overloaded this with initialize(level) and marked the other as deprecated
  • Adds unit test
  • Bumps Rust FFI submodule to recent release version for better log phrasing/behavior
Screenshot 2026-05-19 at 9 38 55 AM

Minor unrelated changes that happened along the way:

  • Also implements panic event the same way Python does
  • Hardened AGENTS.md language around format/tidy

Testing

Added unit test to verify behavior across Error, Warn, Info and Debug levels (Trace not logged in Rust side).

Comment thread src/livekit.cpp
return ffi_client.initialize(true);
}

bool isInitialized() { return FfiClient::instance().isInitialized(); }
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This accidentally made it in from an older PR (no header signature equivalent)

Comment thread src/livekit.cpp
// Initializes logger if singleton instance is not already initialized
setLogLevel(level);
auto& ffi_client = FfiClient::instance();
return ffi_client.initialize(log_sink == LogSink::kCallback);
Copy link
Copy Markdown
Collaborator Author

@alan-george-lk alan-george-lk May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log_sink variable was not working as I suspect it was intended previously. The argument to FfiClient::initialize here was to enable FFI logging (forwards all Rust log macros over the FFI callback as events), but LogSink::kCallback as a sink type is basically irrelevant to that feature. And passing that value here didn't actually register any callbacks. We should figure out what to do here, options are:

  • Breaking change: simply remove the second arg to livekit::initialize()
  • Just leave this .initialize(true) as-is
  • Add a third enum value to LogSink called kOff, and then this arg becomes .initialize(log_sink != kOff), so users have the ability to turn off the FFI logs. But then that brings up the question, we probably should have a cleaner log control. Just turning off FFI logs while others remain doesn't really make sense

@alan-george-lk alan-george-lk marked this pull request as ready for review May 19, 2026 17:55
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