mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-05-29 13:31:27 +02:00
fmt
This commit is contained in:
@@ -13,6 +13,7 @@ There are three general methods of installation that we can recommend.
|
||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||
|
||||
`src-tauri/Cargo.toml`
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
|
||||
@@ -26,7 +27,7 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa
|
||||
pnpm add https://github.com/tauri-apps/tauri-plugin-log
|
||||
# or
|
||||
npm add https://github.com/tauri-apps/tauri-plugin-log
|
||||
# or
|
||||
# or
|
||||
yarn add https://github.com/tauri-apps/tauri-plugin-log
|
||||
```
|
||||
|
||||
@@ -35,6 +36,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-log
|
||||
First you need to register the core plugin with Tauri:
|
||||
|
||||
`src-tauri/src/main.rs`
|
||||
|
||||
```rust
|
||||
use tauri_plugin_log::{LogTarget};
|
||||
|
||||
@@ -53,17 +55,17 @@ fn main() {
|
||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||
|
||||
```javascript
|
||||
import { trace, info, error, attachConsole } from 'tauri-plugin-log-api'
|
||||
import { trace, info, error, attachConsole } from "tauri-plugin-log-api";
|
||||
|
||||
// with LogTarget::Webview enabled this function will print logs to the browser console
|
||||
const detach = await attachConsole()
|
||||
const detach = await attachConsole();
|
||||
|
||||
trace("Trace")
|
||||
info("Info")
|
||||
error("Error")
|
||||
trace("Trace");
|
||||
info("Info");
|
||||
error("Error");
|
||||
|
||||
// detach the browser console from the log stream
|
||||
detach()
|
||||
detach();
|
||||
```
|
||||
|
||||
To log from rust code, add the log crate to your `Cargo.toml`:
|
||||
|
||||
Reference in New Issue
Block a user