mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-20 21:20:42 +02:00
docs(log): update readme code example for v2 (#869)
This commit is contained in:
@@ -49,14 +49,14 @@ First you need to register the core plugin with Tauri:
|
|||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use tauri_plugin_log::{LogTarget};
|
use tauri_plugin_log::{Target, TargetKind};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_log::Builder::default().targets([
|
.plugin(tauri_plugin_log::Builder::new().targets([
|
||||||
LogTarget::LogDir,
|
Target::new(TargetKind::Stdout),
|
||||||
LogTarget::Stdout,
|
Target::new(TargetKind::LogDir { file_name: None }),
|
||||||
LogTarget::Webview,
|
Target::new(TargetKind::Webview),
|
||||||
]).build())
|
]).build())
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
@@ -68,7 +68,7 @@ Afterwards all the plugin's APIs are available through the JavaScript guest bind
|
|||||||
```javascript
|
```javascript
|
||||||
import { trace, info, error, attachConsole } from "@tauri-apps/plugin-log";
|
import { trace, info, error, attachConsole } from "@tauri-apps/plugin-log";
|
||||||
|
|
||||||
// with LogTarget::Webview enabled this function will print logs to the browser console
|
// with TargetKind::Webview enabled this function will print logs to the browser console
|
||||||
const detach = await attachConsole();
|
const detach = await attachConsole();
|
||||||
|
|
||||||
trace("Trace");
|
trace("Trace");
|
||||||
|
|||||||
Reference in New Issue
Block a user