tauri_plugin_debug_tools/
lib.rs1use tauri::{
2 plugin::{Builder, TauriPlugin},
3 Manager, Runtime,
4};
5use tauri_plugin_log::{Target, TargetKind};
6
7mod commands;
8
9pub fn init<R: Runtime>() -> TauriPlugin<R> {
10 Builder::new("debug-tools")
11 .setup(|app, _api| {
12 let log_plugin = tauri_plugin_log::Builder::new()
13 .targets([
14 Target::new(TargetKind::Stdout),
15 Target::new(TargetKind::LogDir {
16 file_name: Some("debug.log".to_string()),
17 }),
18 Target::new(TargetKind::Webview),
19 ])
20 .max_file_size(50_000) .build();
22 let screenshots_plugin = tauri_plugin_screenshots::init();
23
24 let handle = app.app_handle().clone();
25 std::thread::spawn(move || {
26 let _ = handle.plugin(log_plugin);
27 let _ = handle.plugin(screenshots_plugin);
28 });
29
30 Ok(())
31 })
32 .invoke_handler(tauri::generate_handler![
33 commands::capture_webview_state,
34 commands::get_console_logs,
35 commands::send_debug_command,
36 commands::append_debug_logs,
37 commands::reset_debug_logs,
38 commands::write_debug_snapshot,
39 ])
40 .build()
41}