Skip to content

Conversation

@zshipko
Copy link
Contributor

@zshipko zshipko commented Nov 10, 2023

  • Uses tracing instead of log crate
  • Uses tracing-subscriber instead of fern
    • This allows us to automatically capture log events using tracing-subscriber
  • Breaking: Makes extism::set_log_file private and only used through the C API, Rust users should use tracing-subscriber to determine which filters/levels to log.
  • Adds extism::set_log_callback function to set a callback that can be used for custom logging from Rust.
  • Adds bool extism_log_custom(const char *level) and extism_log_drain(void (*fn)(const char *s, size_t length) to the C API to enable custom sinks in other SDKs

@zshipko zshipko changed the title cleanup: use tracing crate for logging refactor!: use tracing crate for logging Nov 13, 2023
@zshipko
Copy link
Contributor Author

zshipko commented Nov 13, 2023

@mhmd-azeez I just pushed a commit to add extism_log_callback, which should allow users to handle logging themselves from other SDKs. If it works for you I will merge this.

@zshipko zshipko changed the title refactor!: use tracing crate for logging refactor!: use tracing crate for logging, add extism_log_callback function Nov 13, 2023
@mhmd-azeez
Copy link
Contributor

@mhmd-azeez I just pushed a commit to add extism_log_callback, which should allow users to handle logging themselves from other SDKs. If it works for you I will merge this.

Just saw this comment. I took a quick look and it looks good, but I will take a deeper look and try to implement it tomorrow. will keep you updated

@zshipko
Copy link
Contributor Author

zshipko commented Nov 14, 2023

I'm running into an issue with Python where tracing-subscriber continues to call the logging function even after the Python runtime has cleaned up and realized that the log function can be called because of logging that happens in a Rust background thread, which makes it pretty tricky to handle correctly.

I am going to try to change the design to make it so the logs are buffered and the SDK calls a function like extism_log_drain to handle the buffered logs.

@zshipko
Copy link
Contributor Author

zshipko commented Nov 14, 2023

Alright, just pushed a change to use extism_log_custom(log_level) and extism_log_drain(callback) instead of the single extism_log_callback(callback, level) function

@zshipko
Copy link
Contributor Author

zshipko commented Nov 16, 2023

@mhmd-azeez merging this now, but happy to make any adjustments if you end up running into any issues.

@zshipko zshipko merged commit 2a24d13 into main Nov 16, 2023
@zshipko zshipko deleted the use-tracing branch November 16, 2023 18:35
zshipko pushed a commit to extism/ocaml-sdk that referenced this pull request Nov 19, 2023
chrisdickinson pushed a commit to extism/python-sdk that referenced this pull request Dec 16, 2023
Support for extism/extism#578

Update to `extism_sys==^1.0.0-rc7`

---------

Co-authored-by: Chris Dickinson <chris@dylibso.com>
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.

3 participants