tauri-plugin-debug-tools 0.1.1 → 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 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 the system temp directory (for example, `/tmp/tauri_console_logs.jsonl`) via Tauri IPC. This avoids blocking the main thread and provides resilience against IPC failures.
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("tauri_console_logs.jsonl");
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 system temp dir (for example, `/tmp/tauri_console_logs.jsonl`)
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
 
package/README.md CHANGED
@@ -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 | System temp dir (e.g., `/tmp/tauri_console_logs.jsonl`) |
143
- | `reset_debug_logs` | Clear log file | File path |
144
- | `write_debug_snapshot` | Save debug snapshot | System temp dir (e.g., `/tmp/tauri_debug_snapshot_*.json`) |
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/tauri_console_logs.jsonl"]
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.0"
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.0"
3964
+ version = "0.1.2"
3965
3965
  dependencies = [
3966
3966
  "serde",
3967
3967
  "serde_json",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "examples-demo-app"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "A Tauri App"
5
5
  authors = ["8beeeaaat <8beeeaaat@gmail.com>"]
6
6
  license = "MIT OR Apache-2.0"
@@ -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("tauri_console_logs.jsonl", 20_000);
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("tauri_console_logs.jsonl", 20_000);
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, "tauri_console_logs.jsonl"),
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, "tauri_console_logs.jsonl"),
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.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>",
@@ -55,7 +55,39 @@ const imagePath = await captureMainWindow();
55
55
 
56
56
  ### Step 3: Collect Console Logs
57
57
 
58
- **Automatic Collection (Recommended)**:
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
- **Log Locations**:
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/tauri_console_logs.jsonl
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/tauri_console_logs.jsonl` (default)
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 [ -f "/tmp/tauri_console_logs.jsonl" ]; then
102
- log_size=$(wc -l < /tmp/tauri_console_logs.jsonl | tr -d ' ')
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
- // Use platform temp directory to avoid hardcoded /tmp paths.
37
- std::env::temp_dir().join("tauri_console_logs.jsonl")
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(logs: Vec<ConsoleLogEntryPayload>) -> Result<String, String> {
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)