Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log plugin compat #158

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

log plugin compat #158

wants to merge 5 commits into from

Conversation

CrabNejonas
Copy link
Contributor

@CrabNejonas CrabNejonas commented Dec 12, 2023

This adds compatibility with the JS commands from the tauri-plugin-log by intercepting calls to the log command and emitting them to the unified data stream.
This also adds handling for properly displaying the source code location of JS messages if available.

builds on #159

resolves #150 resolves DT-69

The `tracing-log` interop layer reports log metadata in a different format, this PR adds handling for these special metadata keys to improve the quality of reported log metadata
Since devtools is incompatible with the log plugin anyway (it serves the same purpose too but better) it would be handy for it to fully replace the log plugin during development.

This PR adds the last missing piece of interop with the log plugin by intercepting the JS log messages and emitting them to the same log stream as all other messages.
Copy link

netlify bot commented Dec 12, 2023

Deploy Preview for cn-devtools-app ready!

Name Link
🔨 Latest commit 5025d80
🔍 Latest deploy log https://app.netlify.com/sites/cn-devtools-app/deploys/65786701e4f240000819141e
😎 Deploy Preview https://deploy-preview-158--cn-devtools-app.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 12, 2023

Deploy Preview for cn-devtools-website canceled.

Name Link
🔨 Latest commit 5025d80
🔍 Latest deploy log https://app.netlify.com/sites/cn-devtools-website/deploys/65786701623b650008289afa

tauri::plugin::Builder::new("probe")
// we pretend to be the log plugin so we can intercept the commands
// this plugin is incompatible with the log plugin anyway
tauri::plugin::Builder::new("log")

Choose a reason for hiding this comment

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

I don't really like this.. I feel if someone is using devtools, they shouldn't need the log plugin. We should document that instead (e.g. use the log plugin on production, devtools on development).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that is the idea, but as stated in the issue #150 devtools misses out the one feature that makes tauri-plugin-log great: the ability to emit logs from both Rust and JS to the same place.

Choose a reason for hiding this comment

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

what do you think about making the log plugin not crash on init? so you can keep using its APIs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that could work actually

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gonna be difficult though, bc we have to init the log plugin in the setup callback not the builder function

Choose a reason for hiding this comment

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

why does it matter? as long as we tell people to enable devtools first and both register at the same place..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean like this?

tauri::Builder::default()
    .plugin(devtools::init())
    .plugin(tauri_plugin_log::init())

Choose a reason for hiding this comment

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

yeah (plus where we actually register the log plugin)

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.

Compatibility with tauri-plugin-log
2 participants