I'm working on a C wrapper for Rustls. One of the main uses will be an optional backend for libcurl. Rustls uses the
log crate for logging. I'd like to plumb through those log messages to
libcurl, and in turn to any users of
libcurl. For instance, users of
libcurl can receive debug information by setting CURLOPT_DEBUGFUNCTION and CURLOPT_DEBUGDATA.
I think what I need to do is define an implementation of the
Log trait in my wrapper, define a global instance of it, and provide a pair of functions
unregister_log_callback, so that clients like
libcurl can register a callback that is specific to their implementation.
A few questions:
- Does this make sense?
- Has anyone implemented something similar?
- Is there any good way to deal with the fact that a given binary might depend on crustls through multiple paths, and would therefore potentially get debug logs twice? For instance, a git client might depend on libcurl->crustls, and also libgit->crustls, each of which could potentially register a log callback.