tauri-plugin-debug-tools 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -4
- package/README.md +28 -5
- package/examples/src-tauri/Cargo.lock +2 -2
- package/examples/src-tauri/Cargo.toml +4 -2
- package/examples/tests/e2e.mac.test.ts +2 -2
- package/examples/tests/e2e.test.ts +2 -2
- package/package.json +6 -1
- package/skills/debug-tauri/SKILL.md +34 -2
- package/skills/debug-tauri/references/TROUBLESHOOTING.md +2 -2
- package/skills/debug-tauri/scripts/validate_setup.sh +3 -2
- package/src/commands.rs +19 -7
package/AGENTS.md
CHANGED
|
@@ -50,7 +50,7 @@ tauri-plugin-debug-tools/
|
|
|
50
50
|
- **Stack Trace Normalization**: Filters internal frames
|
|
51
51
|
- **Zero Dependencies**: No Safari DevTools required
|
|
52
52
|
|
|
53
|
-
**Key Design Decision**: Logs are collected in-memory on the frontend and periodically flushed to
|
|
53
|
+
**Key Design Decision**: Logs are collected in-memory on the frontend and periodically flushed to `/tmp` directory (for example, `/tmp/tauri_console_logs_app_name_12345.jsonl`) via Tauri IPC. This avoids blocking the main thread and provides resilience against IPC failures.
|
|
54
54
|
|
|
55
55
|
### 2. Event-Based Debug Commands
|
|
56
56
|
|
|
@@ -212,7 +212,7 @@ For cross-platform support:
|
|
|
212
212
|
```rust
|
|
213
213
|
// Use this instead of "/tmp/"
|
|
214
214
|
let temp_dir = std::env::temp_dir();
|
|
215
|
-
let log_path = temp_dir.join("
|
|
215
|
+
let log_path = temp_dir.join(format!("tauri_console_logs_{}_{}.jsonl", app_name, pid));
|
|
216
216
|
```
|
|
217
217
|
|
|
218
218
|
### Performance Considerations
|
|
@@ -266,7 +266,7 @@ When making changes, verify:
|
|
|
266
266
|
- [ ] Plugin registers in host app without errors
|
|
267
267
|
- [ ] IPC commands return expected results
|
|
268
268
|
- [ ] Console logger captures logs correctly
|
|
269
|
-
- [ ] Logs flush to
|
|
269
|
+
- [ ] Logs flush to `/tmp` (for example, `/tmp/tauri_console_logs_app_name_12345.jsonl`)
|
|
270
270
|
- [ ] Agent skill can be invoked (`/debug-tauri`)
|
|
271
271
|
- [ ] Screenshot capture works (macOS)
|
|
272
272
|
|
|
@@ -342,5 +342,5 @@ For questions or issues:
|
|
|
342
342
|
---
|
|
343
343
|
|
|
344
344
|
**Last Updated**: 2025-12-31
|
|
345
|
-
**Version**: 0.1.
|
|
345
|
+
**Version**: 0.1.1
|
|
346
346
|
**Maintainer**: (your name/team)
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Add to your Tauri project's `Cargo.toml`:
|
|
|
19
19
|
|
|
20
20
|
```toml
|
|
21
21
|
[dependencies]
|
|
22
|
-
tauri-plugin-debug-tools = "0.1.
|
|
22
|
+
tauri-plugin-debug-tools = "0.1.1"
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Install the frontend package:
|
|
@@ -139,9 +139,32 @@ All commands are available through the Tauri IPC system:
|
|
|
139
139
|
| `capture_webview_state` | Capture WebView state | `WebViewState` JSON |
|
|
140
140
|
| `get_console_logs` | Legacy console logs | Empty array (use frontend logger) |
|
|
141
141
|
| `send_debug_command` | Send event to frontend | Success message |
|
|
142
|
-
| `append_debug_logs` | Append logs to file |
|
|
143
|
-
| `reset_debug_logs` | Clear log file |
|
|
144
|
-
| `write_debug_snapshot` | Save debug snapshot |
|
|
142
|
+
| `append_debug_logs` | Append logs to file | Returns actual file path string |
|
|
143
|
+
| `reset_debug_logs` | Clear log file | Returns actual file path string |
|
|
144
|
+
| `write_debug_snapshot` | Save debug snapshot | Returns actual file path string |
|
|
145
|
+
|
|
146
|
+
#### Finding Log File Locations
|
|
147
|
+
|
|
148
|
+
Both `reset_debug_logs` and `append_debug_logs` commands return the actual file path where logs are stored:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { invoke } from '@tauri-apps/api/core';
|
|
152
|
+
|
|
153
|
+
// Get log file path
|
|
154
|
+
const logPath = await invoke('plugin:debug-tools|reset_debug_logs');
|
|
155
|
+
console.log('Logs are stored at:', logPath);
|
|
156
|
+
// Example output: "/tmp/tauri_console_logs_hoge_12345.jsonl"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Platform-specific locations:**
|
|
160
|
+
|
|
161
|
+
- **macOS**: `/tmp/tauri_console_logs_[app_name]_[pid].jsonl`
|
|
162
|
+
- **Linux**: `/tmp/tauri_console_logs_[app_name]_[pid].jsonl`
|
|
163
|
+
- **Windows**: `%TEMP%\tauri_console_logs_[app_name]_[pid].jsonl` (e.g., `C:\Users\...\AppData\Local\Temp\`)
|
|
164
|
+
|
|
165
|
+
Where `[app_name]` is the application name from `package_info` and `[pid]` is the process ID.
|
|
166
|
+
|
|
167
|
+
The exact path is determined by Rust's `std::env::temp_dir()` and may vary between systems.
|
|
145
168
|
|
|
146
169
|
## AI Agent Skill
|
|
147
170
|
|
|
@@ -233,7 +256,7 @@ flowchart TB
|
|
|
233
256
|
CL -->|"Batch flush"| Plugin
|
|
234
257
|
end
|
|
235
258
|
|
|
236
|
-
FS["File System<br/>Temp dir (logs & snapshots)<br/>e.g., /tmp/
|
|
259
|
+
FS["File System<br/>Temp dir (logs & snapshots)<br/>e.g., /tmp/tauri_console_logs_app_12345.jsonl"]
|
|
237
260
|
|
|
238
261
|
Plugin -->|"Write logs & snapshots"| FS
|
|
239
262
|
end
|
|
@@ -1004,7 +1004,7 @@ dependencies = [
|
|
|
1004
1004
|
|
|
1005
1005
|
[[package]]
|
|
1006
1006
|
name = "examples-demo-app"
|
|
1007
|
-
version = "0.1.
|
|
1007
|
+
version = "0.1.2"
|
|
1008
1008
|
dependencies = [
|
|
1009
1009
|
"serde",
|
|
1010
1010
|
"serde_json",
|
|
@@ -3961,7 +3961,7 @@ dependencies = [
|
|
|
3961
3961
|
|
|
3962
3962
|
[[package]]
|
|
3963
3963
|
name = "tauri-plugin-debug-tools"
|
|
3964
|
-
version = "0.1.
|
|
3964
|
+
version = "0.1.2"
|
|
3965
3965
|
dependencies = [
|
|
3966
3966
|
"serde",
|
|
3967
3967
|
"serde_json",
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "examples-demo-app"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.2"
|
|
4
4
|
description = "A Tauri App"
|
|
5
|
-
authors = ["
|
|
5
|
+
authors = ["8beeeaaat <8beeeaaat@gmail.com>"]
|
|
6
|
+
license = "MIT OR Apache-2.0"
|
|
7
|
+
repository = "https://github.com/8beeeaaat/tauri-plugin-debug-tools"
|
|
6
8
|
edition = "2021"
|
|
7
9
|
|
|
8
10
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
@@ -175,7 +175,7 @@ suite("Tauri E2E (Appium Mac2)", () => {
|
|
|
175
175
|
throw new Error("debug-reset-logs not found");
|
|
176
176
|
}
|
|
177
177
|
await resetLogs.click();
|
|
178
|
-
await waitForSourceIncludes("
|
|
178
|
+
await waitForSourceIncludes("tauri_console_logs_", 20_000);
|
|
179
179
|
|
|
180
180
|
const appendLogs = await waitForLocator(
|
|
181
181
|
"debug-append-logs",
|
|
@@ -185,7 +185,7 @@ suite("Tauri E2E (Appium Mac2)", () => {
|
|
|
185
185
|
throw new Error("debug-append-logs not found");
|
|
186
186
|
}
|
|
187
187
|
await appendLogs.click();
|
|
188
|
-
await waitForSourceIncludes("
|
|
188
|
+
await waitForSourceIncludes("tauri_console_logs_", 20_000);
|
|
189
189
|
|
|
190
190
|
const snapshot = await waitForLocator(
|
|
191
191
|
"debug-write-snapshot",
|
|
@@ -107,14 +107,14 @@ suite("Tauri E2E (tauri-driver)", () => {
|
|
|
107
107
|
const resetLogs = await driver.findElement(By.id("debug-reset-logs"));
|
|
108
108
|
await resetLogs.click();
|
|
109
109
|
await driver.wait(
|
|
110
|
-
until.elementTextContains(logsOutput, "
|
|
110
|
+
until.elementTextContains(logsOutput, "tauri_console_logs_"),
|
|
111
111
|
10_000,
|
|
112
112
|
);
|
|
113
113
|
|
|
114
114
|
const appendLogs = await driver.findElement(By.id("debug-append-logs"));
|
|
115
115
|
await appendLogs.click();
|
|
116
116
|
await driver.wait(
|
|
117
|
-
until.elementTextContains(logsOutput, "
|
|
117
|
+
until.elementTextContains(logsOutput, "tauri_console_logs_"),
|
|
118
118
|
10_000,
|
|
119
119
|
);
|
|
120
120
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tauri-plugin-debug-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Comprehensive debug utilities for Tauri WebView applications with AI-powered automated debugging workflows",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"author": "8beeeaaat <8beeeaaat@gmail.com>",
|
|
@@ -80,5 +80,10 @@
|
|
|
80
80
|
"npm-run-all": "^4.1.5",
|
|
81
81
|
"typescript": "^5.9.3",
|
|
82
82
|
"vitest": "^4.0.16"
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public",
|
|
86
|
+
"provenance": true,
|
|
87
|
+
"registry": "https://registry.npmjs.org"
|
|
83
88
|
}
|
|
84
89
|
}
|
|
@@ -55,7 +55,39 @@ const imagePath = await captureMainWindow();
|
|
|
55
55
|
|
|
56
56
|
### Step 3: Collect Console Logs
|
|
57
57
|
|
|
58
|
-
**
|
|
58
|
+
**Console Logger (Frontend - Recommended)**:
|
|
59
|
+
|
|
60
|
+
The `consoleLogger` automatically collects frontend logs and errors in a ring buffer and flushes them to a temp file.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// Import at app entry point to initialize automatic collection
|
|
64
|
+
import "tauri-plugin-debug-tools/consoleLogger";
|
|
65
|
+
|
|
66
|
+
// Use debugTools for explicit logging
|
|
67
|
+
import { debugTools } from "tauri-plugin-debug-tools/consoleLogger";
|
|
68
|
+
debugTools.log("App started");
|
|
69
|
+
debugTools.error("Something went wrong");
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Finding consoleLogger Log Files**:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { invoke } from '@tauri-apps/api/core';
|
|
76
|
+
|
|
77
|
+
// Get actual log file path
|
|
78
|
+
const logPath = await invoke('plugin:debug-tools|reset_debug_logs');
|
|
79
|
+
console.log('Console logs stored at:', logPath);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Platform-specific consoleLogger locations**:
|
|
83
|
+
|
|
84
|
+
- **macOS**: `/tmp/tauri_console_logs_[app_name]_[pid].jsonl`
|
|
85
|
+
- **Linux**: `/tmp/tauri_console_logs_[app_name]_[pid].jsonl`
|
|
86
|
+
- **Windows**: `%TEMP%\tauri_console_logs_[app_name]_[pid].jsonl`
|
|
87
|
+
|
|
88
|
+
Where `[app_name]` is the application name and `[pid]` is the process ID.
|
|
89
|
+
|
|
90
|
+
**Backend Logs (tauri-plugin-log)**:
|
|
59
91
|
|
|
60
92
|
```typescript
|
|
61
93
|
import { logger } from "tauri-plugin-debug-tools/logAdapter";
|
|
@@ -68,7 +100,7 @@ logger.info("App started");
|
|
|
68
100
|
logger.error("Something went wrong");
|
|
69
101
|
```
|
|
70
102
|
|
|
71
|
-
**
|
|
103
|
+
**Backend log locations**:
|
|
72
104
|
|
|
73
105
|
- **macOS**: `~/Library/Logs/{bundle_id}/debug.log`
|
|
74
106
|
- **Linux**: `~/.local/share/{bundle_id}/logs/debug.log`
|
|
@@ -66,7 +66,7 @@ initConsoleLogger();
|
|
|
66
66
|
**Option 2**: Check log file exists
|
|
67
67
|
|
|
68
68
|
```bash
|
|
69
|
-
ls -lh /tmp/
|
|
69
|
+
ls -lh /tmp/tauri_console_logs_*.jsonl
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
**Option 3**: Use IPC method
|
|
@@ -140,5 +140,5 @@ If issues persist:
|
|
|
140
140
|
|
|
141
141
|
**Log output:**
|
|
142
142
|
|
|
143
|
-
- `/tmp/
|
|
143
|
+
- `/tmp/tauri_console_logs_[app_name]_[pid].jsonl`
|
|
144
144
|
- `/tmp/tauri_debug_*.png` (screenshots)
|
|
@@ -98,8 +98,9 @@ fi
|
|
|
98
98
|
# Check for legacy log file
|
|
99
99
|
echo ""
|
|
100
100
|
echo "📝 Legacy Logs (consoleLogger):"
|
|
101
|
-
if
|
|
102
|
-
|
|
101
|
+
if compgen -G "/tmp/tauri_console_logs_*.jsonl" > /dev/null; then
|
|
102
|
+
log_file=$(ls -t /tmp/tauri_console_logs_*.jsonl 2>/dev/null | head -1)
|
|
103
|
+
log_size=$(wc -l < "$log_file" | tr -d ' ')
|
|
103
104
|
echo " ⚠️ Legacy log file exists ($log_size lines)"
|
|
104
105
|
echo " 💡 Migrate to tauri-plugin-log for better persistence"
|
|
105
106
|
else
|
package/src/commands.rs
CHANGED
|
@@ -32,9 +32,18 @@ pub struct ConsoleLogEntryPayload {
|
|
|
32
32
|
pub stack_trace: Option<String>,
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
fn console_log_path() -> PathBuf {
|
|
36
|
-
//
|
|
37
|
-
|
|
35
|
+
fn console_log_path<R: Runtime>(app: &AppHandle<R>) -> PathBuf {
|
|
36
|
+
// Get application name from AppHandle
|
|
37
|
+
let app_name = app.package_info().name.replace(" ", "_");
|
|
38
|
+
// Get current process ID
|
|
39
|
+
let pid = std::process::id();
|
|
40
|
+
// Use /tmp on Unix-like systems, temp_dir() on Windows
|
|
41
|
+
#[cfg(unix)]
|
|
42
|
+
let base_dir = PathBuf::from("/tmp");
|
|
43
|
+
#[cfg(not(unix))]
|
|
44
|
+
let base_dir = std::env::temp_dir();
|
|
45
|
+
|
|
46
|
+
base_dir.join(format!("tauri_console_logs_{}_{}.jsonl", app_name, pid))
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
/// Get WebView state.
|
|
@@ -97,12 +106,15 @@ pub async fn send_debug_command<R: Runtime>(
|
|
|
97
106
|
|
|
98
107
|
/// Append console logs to /tmp.
|
|
99
108
|
#[tauri::command]
|
|
100
|
-
pub async fn append_debug_logs
|
|
109
|
+
pub async fn append_debug_logs<R: Runtime>(
|
|
110
|
+
app: AppHandle<R>,
|
|
111
|
+
logs: Vec<ConsoleLogEntryPayload>,
|
|
112
|
+
) -> Result<String, String> {
|
|
101
113
|
if logs.is_empty() {
|
|
102
114
|
return Ok("no logs".to_string());
|
|
103
115
|
}
|
|
104
116
|
|
|
105
|
-
let path = console_log_path();
|
|
117
|
+
let path = console_log_path(&app);
|
|
106
118
|
let mut file = std::fs::OpenOptions::new()
|
|
107
119
|
.create(true)
|
|
108
120
|
.append(true)
|
|
@@ -121,8 +133,8 @@ pub async fn append_debug_logs(logs: Vec<ConsoleLogEntryPayload>) -> Result<Stri
|
|
|
121
133
|
|
|
122
134
|
/// Reset the console log file.
|
|
123
135
|
#[tauri::command]
|
|
124
|
-
pub async fn reset_debug_logs() -> Result<String, String> {
|
|
125
|
-
let path = console_log_path();
|
|
136
|
+
pub async fn reset_debug_logs<R: Runtime>(app: AppHandle<R>) -> Result<String, String> {
|
|
137
|
+
let path = console_log_path(&app);
|
|
126
138
|
std::fs::OpenOptions::new()
|
|
127
139
|
.create(true)
|
|
128
140
|
.write(true)
|