From b0b16e7fdfeb2427213c816fc2854e76c7e50d2d Mon Sep 17 00:00:00 2001 From: nothingismagick Date: Tue, 31 Dec 2019 19:01:48 +0100 Subject: [PATCH] Created 08. App Debugging (markdown) --- 08.-App-Debugging.md | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 08.-App-Debugging.md diff --git a/08.-App-Debugging.md b/08.-App-Debugging.md new file mode 100644 index 0000000..cf1ad33 --- /dev/null +++ b/08.-App-Debugging.md @@ -0,0 +1,55 @@ +# Debugging +With all the moving pieces in tauri, you may need to investigate what is happening - or going wrong. There are several consoles that will help you discover what's going on where and give you insight into what is going wrong. + +## Rust Console +When you run a tauri app (except when it has been bundled and you are running that bundle) you will have a rust console available. This is in the terminal where you ran e.g. `tauri dev`. You can use the following code to print something to that console from within a rust file: +``` +println!("Message from rust: {}", msg); +``` + +Sometimes you may have an error in your rust code, and the rust compiler can give you lots of information. If, for example, `tauri dev` crashes, you can rerun it like this on Linux and MacOS: +``` +RUST_DEBUG=1 tauri dev +``` +or like this on MS Windows: +``` +set RUST_DEBUG=1 +tauri dev +``` + +This will give you a granular stack trace. Generally speaking, the rust compiler will help you by +giving you detailed information about the issue, such as: + +``` +For more information about this error, try `rustc --explain E0433` +``` + +## Webview JS Console +### Linux & MacOS +Right click in the webview, and choose `Inspect Element`. This will open up a web-inspector, as you are used to seeing and using it. +### Windows +If you enable the Edge backend (web-view = { version = "*", features = ["edge"] } in Cargo.toml) you can use the standalone Edge DevTools app. + +This enables you to connect the dev tools to your Rust-backed web view as if it were a normal Edge window. (Thanks to @dkaste for providing the solution [in this issue](https://github.com/Boscop/web-view/issues/88#issuecomment-552464137). + +If you are using MSHTML, then you will probably have to use firebug: +``` + +``` +See [this thread](https://github.com/zserge/webview/blob/master/README.md#debugging-and-development-tips) for more information. + +## Create a debugging BUILD +There are cases where you might need to inspect the JS console in the final bundle, so tauri provides a simple command to create a debugging bundle: + +``` +local: yarn tauri build --debug +global: tauri build --debug +``` + +Like the normal build and dev processes, the first time you run this it will take more time than subsequent runs. However, the final bundled app will be placed in `src-tauri/target/debug/bundle`. That app will ship with the development console enabled. + +## Run your app from the terminal +You can also run a built app from the terminal, which will also give you the rust compiler notes (in case of errors) or your `println` messages. Just find the file `src-tauri/target/release/app` and either double click it (but be warned, the terminal will close on errors) or just run it in directly in your console. + +# Next Step: +[Modes]()