tauri-plugin-debug-tools 0.1.0

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.
Files changed (82) hide show
  1. package/AGENTS.md +346 -0
  2. package/LICENSE +21 -0
  3. package/README.md +303 -0
  4. package/dist-js/consoleLogger.d.ts +92 -0
  5. package/dist-js/consoleLogger.d.ts.map +1 -0
  6. package/dist-js/consoleLogger.js +317 -0
  7. package/dist-js/debugBridge.d.ts +50 -0
  8. package/dist-js/debugBridge.d.ts.map +1 -0
  9. package/dist-js/debugBridge.js +66 -0
  10. package/dist-js/index.d.ts +3 -0
  11. package/dist-js/index.d.ts.map +1 -0
  12. package/dist-js/index.js +2 -0
  13. package/dist-js/logAdapter.d.ts +36 -0
  14. package/dist-js/logAdapter.d.ts.map +1 -0
  15. package/dist-js/logAdapter.js +42 -0
  16. package/dist-js/screenshotHelper.d.ts +60 -0
  17. package/dist-js/screenshotHelper.d.ts.map +1 -0
  18. package/dist-js/screenshotHelper.js +100 -0
  19. package/examples/.vscode/extensions.json +3 -0
  20. package/examples/README.md +51 -0
  21. package/examples/bun.lock +265 -0
  22. package/examples/package.json +19 -0
  23. package/examples/src/assets/javascript.svg +1 -0
  24. package/examples/src/assets/tauri.svg +6 -0
  25. package/examples/src/index.html +56 -0
  26. package/examples/src/main.js +91 -0
  27. package/examples/src/styles.css +112 -0
  28. package/examples/src-tauri/Cargo.lock +5674 -0
  29. package/examples/src-tauri/Cargo.toml +25 -0
  30. package/examples/src-tauri/build.rs +3 -0
  31. package/examples/src-tauri/capabilities/default.json +7 -0
  32. package/examples/src-tauri/icons/128x128.png +0 -0
  33. package/examples/src-tauri/icons/128x128@2x.png +0 -0
  34. package/examples/src-tauri/icons/32x32.png +0 -0
  35. package/examples/src-tauri/icons/Square107x107Logo.png +0 -0
  36. package/examples/src-tauri/icons/Square142x142Logo.png +0 -0
  37. package/examples/src-tauri/icons/Square150x150Logo.png +0 -0
  38. package/examples/src-tauri/icons/Square284x284Logo.png +0 -0
  39. package/examples/src-tauri/icons/Square30x30Logo.png +0 -0
  40. package/examples/src-tauri/icons/Square310x310Logo.png +0 -0
  41. package/examples/src-tauri/icons/Square44x44Logo.png +0 -0
  42. package/examples/src-tauri/icons/Square71x71Logo.png +0 -0
  43. package/examples/src-tauri/icons/Square89x89Logo.png +0 -0
  44. package/examples/src-tauri/icons/StoreLogo.png +0 -0
  45. package/examples/src-tauri/icons/icon.icns +0 -0
  46. package/examples/src-tauri/icons/icon.ico +0 -0
  47. package/examples/src-tauri/icons/icon.png +0 -0
  48. package/examples/src-tauri/src/lib.rs +15 -0
  49. package/examples/src-tauri/src/main.rs +6 -0
  50. package/examples/src-tauri/tauri.conf.json +33 -0
  51. package/examples/tests/e2e.mac.test.ts +203 -0
  52. package/examples/tests/e2e.test.ts +131 -0
  53. package/examples/vitest.config.ts +10 -0
  54. package/guest-js/consoleLogger.ts +369 -0
  55. package/guest-js/debugBridge.ts +93 -0
  56. package/guest-js/index.ts +2 -0
  57. package/guest-js/logAdapter.ts +62 -0
  58. package/guest-js/screenshotHelper.ts +122 -0
  59. package/package.json +84 -0
  60. package/permissions/autogenerated/commands/append_debug_logs.toml +13 -0
  61. package/permissions/autogenerated/commands/capture_webview_state.toml +13 -0
  62. package/permissions/autogenerated/commands/get_console_logs.toml +13 -0
  63. package/permissions/autogenerated/commands/reset_debug_logs.toml +13 -0
  64. package/permissions/autogenerated/commands/send_debug_command.toml +13 -0
  65. package/permissions/autogenerated/commands/write_debug_snapshot.toml +13 -0
  66. package/permissions/autogenerated/reference.md +201 -0
  67. package/permissions/debug-with-logging.toml +26 -0
  68. package/permissions/default.toml +26 -0
  69. package/permissions/schemas/schema.json +384 -0
  70. package/skills/debug-tauri/SKILL.md +114 -0
  71. package/skills/debug-tauri/references/IPC_COMMANDS.md +196 -0
  72. package/skills/debug-tauri/references/LOGGING.md +195 -0
  73. package/skills/debug-tauri/references/MIGRATION.md +487 -0
  74. package/skills/debug-tauri/references/REFERENCE.md +206 -0
  75. package/skills/debug-tauri/references/REPORT_TEMPLATE.md +166 -0
  76. package/skills/debug-tauri/references/SCREENSHOTS.md +193 -0
  77. package/skills/debug-tauri/references/TROUBLESHOOTING.md +144 -0
  78. package/skills/debug-tauri/scripts/analyze_logs.sh +127 -0
  79. package/skills/debug-tauri/scripts/capture.sh +89 -0
  80. package/skills/debug-tauri/scripts/validate_setup.sh +181 -0
  81. package/src/commands.rs +147 -0
  82. package/src/lib.rs +41 -0
@@ -0,0 +1,195 @@
1
+ # Logging with tauri-plugin-log
2
+
3
+ Official Tauri logging plugin integration for automatic console collection and structured logging.
4
+
5
+ ## Quick Start
6
+
7
+ ```typescript
8
+ import { logger } from "tauri-plugin-debug-tools/logAdapter";
9
+
10
+ // Initialize once at app startup
11
+ const detach = await logger.initialize();
12
+
13
+ // Use structured logging
14
+ logger.trace("Detailed trace information");
15
+ logger.debug("Debug information");
16
+ logger.info("Informational message");
17
+ logger.warn("Warning message");
18
+ logger.error("Error occurred");
19
+
20
+ // Cleanup on app shutdown (optional)
21
+ detach();
22
+ ```
23
+
24
+ ## Configuration
25
+
26
+ Plugin is pre-configured in `src/lib.rs` with the following settings:
27
+
28
+ ```rust
29
+ tauri_plugin_log::Builder::new()
30
+ .targets([
31
+ Target::new(TargetKind::Stdout), // Console output
32
+ Target::new(TargetKind::LogDir {
33
+ file_name: Some("debug.log".to_string())
34
+ }), // File logging
35
+ Target::new(TargetKind::Webview), // WebView console
36
+ ])
37
+ .max_file_size(50_000) // 50KB auto-rotation
38
+ .build()
39
+ ```
40
+
41
+ ## Log File Locations
42
+
43
+ Platform-specific paths where logs are automatically saved:
44
+
45
+ ### macOS
46
+
47
+ ```
48
+ ~/Library/Logs/{bundle_identifier}/debug.log
49
+ ```
50
+
51
+ Example: `~/Library/Logs/com.example.myapp/debug.log`
52
+
53
+ ### Linux
54
+
55
+ ```
56
+ ~/.local/share/{bundle_identifier}/logs/debug.log
57
+ ```
58
+
59
+ Example: `~/.local/share/com.example.myapp/logs/debug.log`
60
+
61
+ ### Windows
62
+
63
+ ```
64
+ {FOLDERID_LocalAppData}\{bundle_identifier}\logs\debug.log
65
+ ```
66
+
67
+ Example: `C:\Users\Username\AppData\Local\com.example.myapp\logs\debug.log`
68
+
69
+ ## Log Levels
70
+
71
+ Available log levels in order of severity:
72
+
73
+ 1. **TRACE**: Most detailed information (e.g., function entry/exit)
74
+ 2. **DEBUG**: Diagnostic information useful during development
75
+ 3. **INFO**: General informational messages about app operation
76
+ 4. **WARN**: Warning messages for potentially problematic situations
77
+ 5. **ERROR**: Error messages for failures that don't stop the app
78
+
79
+ ## Automatic Console Forwarding
80
+
81
+ The `attachConsole()` method automatically forwards all `console.*` calls to the plugin:
82
+
83
+ ```typescript
84
+ await logger.initialize();
85
+
86
+ // These are now logged to file AND console
87
+ console.log("This is logged"); // → INFO level
88
+ console.warn("Warning"); // → WARN level
89
+ console.error("Error"); // → ERROR level
90
+ ```
91
+
92
+ ## File Rotation
93
+
94
+ Logs automatically rotate when reaching 50KB size:
95
+
96
+ - Current log: `debug.log`
97
+ - Rotated logs: `debug.log.1`, `debug.log.2`, etc.
98
+ - Old logs are preserved for historical analysis
99
+
100
+ ## Reading Logs
101
+
102
+ ### Via analyze_logs.sh Script
103
+
104
+ ```bash
105
+ # Analyze logs with pattern detection
106
+ ./scripts/analyze_logs.sh
107
+
108
+ # Custom log file path
109
+ ./scripts/analyze_logs.sh /path/to/debug.log
110
+ ```
111
+
112
+ ### Manual Reading
113
+
114
+ ```bash
115
+ # macOS
116
+ cat ~/Library/Logs/com.example.myapp/debug.log
117
+
118
+ # Linux
119
+ cat ~/.local/share/com.example.myapp/logs/debug.log
120
+
121
+ # Windows (PowerShell)
122
+ Get-Content $env:LOCALAPPDATA\com.example.myapp\logs\debug.log
123
+ ```
124
+
125
+ ## Troubleshooting
126
+
127
+ ### Logs Not Being Created
128
+
129
+ 1. **Check initialization**: Ensure `logger.initialize()` is called at app startup
130
+ 2. **Verify permissions**: `log:default` must be enabled in app capabilities
131
+ 3. **Check bundle ID**: Confirm correct bundle identifier in `tauri.conf.json`
132
+
133
+ ### Empty Log Files
134
+
135
+ 1. **No console output**: Call `logger.info()` or other methods to generate logs
136
+ 2. **Console not attached**: Verify `attachConsole()` was awaited successfully
137
+ 3. **Permission denied**: Check file system permissions for log directory
138
+
139
+ ### Cannot Find Log Files
140
+
141
+ ```bash
142
+ # Use environment variable to locate logs
143
+ echo $HOME/Library/Logs/{bundle_id}/debug.log # macOS
144
+ echo $HOME/.local/share/{bundle_id}/logs/debug.log # Linux
145
+ echo $env:LOCALAPPDATA\{bundle_id}\logs\debug.log # Windows
146
+ ```
147
+
148
+ ## Advanced Usage
149
+
150
+ ### Custom Log Targets
151
+
152
+ To modify logging targets, edit `src/lib.rs`:
153
+
154
+ ```rust
155
+ use tauri_plugin_log::{Target, TargetKind};
156
+
157
+ // Add custom target
158
+ .targets([
159
+ Target::new(TargetKind::Stdout),
160
+ Target::new(TargetKind::LogDir {
161
+ file_name: Some("custom.log".to_string())
162
+ }),
163
+ // Add more targets as needed
164
+ ])
165
+ ```
166
+
167
+ ### Log Filtering
168
+
169
+ Filter logs by level in Rust backend:
170
+
171
+ ```rust
172
+ .level(log::LevelFilter::Debug) // Only DEBUG and above
173
+ ```
174
+
175
+ ### Programmatic Log Access
176
+
177
+ Access logs via filesystem APIs:
178
+
179
+ ```typescript
180
+ import { readTextFile } from "@tauri-apps/plugin-fs";
181
+ import { appLogDir } from "@tauri-apps/api/path";
182
+
183
+ const logDir = await appLogDir();
184
+ const logContent = await readTextFile(`${logDir}/debug.log`);
185
+ ```
186
+
187
+ ## Migration from Custom Logger
188
+
189
+ See [MIGRATION.md](MIGRATION.md) for complete migration guide from `consoleLogger.ts`.
190
+
191
+ ## References
192
+
193
+ - [Official tauri-plugin-log Documentation](https://v2.tauri.app/plugin/logging/)
194
+ - [Rust log crate Documentation](https://docs.rs/log/latest/log/)
195
+ - [analyze_logs.sh Script](../scripts/analyze_logs.sh)
@@ -0,0 +1,487 @@
1
+ # Migration Guide: Official Plugins Integration
2
+
3
+ Complete guide for migrating from custom implementations to official Tauri plugins.
4
+
5
+ ## Overview
6
+
7
+ This migration replaces:
8
+
9
+ - **Custom `consoleLogger.ts`** → `tauri-plugin-log` (official)
10
+ - **OS-dependent `screencapture` commands** → `tauri-plugin-screenshots`
11
+ - **macOS-only support** → **Cross-platform** (macOS, Windows, Linux)
12
+
13
+ ## Migration Strategy
14
+
15
+ ### Recommended Approach: Parallel Deployment
16
+
17
+ 1. **Add official plugins alongside existing implementation**
18
+ 2. **Test in development environment**
19
+ 3. **Gradually switch to plugin APIs**
20
+ 4. **Remove custom implementation after validation**
21
+
22
+ ### Complete Migration Timeline
23
+
24
+ - **v0.2.0**: Logging plugin added (parallel with consoleLogger)
25
+ - **v0.3.0**: Screenshots plugin added
26
+ - **v0.4.0**: Custom implementation removed
27
+ - **v1.0.0**: Full cross-platform validation
28
+
29
+ ## Phase 1: Logging Migration
30
+
31
+ ### Before (Custom Implementation)
32
+
33
+ ```typescript
34
+ // guest-js/consoleLogger.ts
35
+ import { invoke } from "@tauri-apps/api/core";
36
+
37
+ export async function appendDebugLogs(message: string): Promise<void> {
38
+ await invoke("plugin:debug-tools|append_debug_logs", { message });
39
+ }
40
+
41
+ export async function getConsoleLogs(): Promise<string[]> {
42
+ return await invoke("plugin:debug-tools|get_console_logs");
43
+ }
44
+
45
+ // Usage
46
+ await appendDebugLogs("App started");
47
+ const logs = await getConsoleLogs();
48
+ ```
49
+
50
+ ### After (Official Plugin)
51
+
52
+ ```typescript
53
+ // guest-js/logAdapter.ts
54
+ import { logger } from "tauri-plugin-debug-tools/logAdapter";
55
+
56
+ // Initialize once at app startup
57
+ const detach = await logger.initialize();
58
+
59
+ // Usage
60
+ logger.info("App started");
61
+
62
+ // Logs automatically saved to platform-specific location
63
+ // No need to manually retrieve logs
64
+ ```
65
+
66
+ ### Key Changes
67
+
68
+ | Aspect | Custom | Official Plugin |
69
+ |--------|---------|-----------------|
70
+ | **Setup** | No initialization required | Requires `attachConsole()` call |
71
+ | **Storage** | In-memory array | File-based with auto-rotation |
72
+ | **Retrieval** | Manual `getConsoleLogs()` | Direct file access |
73
+ | **Levels** | Single log level | trace/debug/info/warn/error |
74
+ | **Persistence** | Lost on app restart | Persistent across restarts |
75
+ | **Cross-platform** | No | Yes (macOS/Windows/Linux) |
76
+
77
+ ### Migration Steps
78
+
79
+ #### 1. Add Dependencies
80
+
81
+ **Cargo.toml**:
82
+
83
+ ```toml
84
+ [dependencies]
85
+ tauri-plugin-log = "2.0"
86
+ ```
87
+
88
+ **package.json**:
89
+
90
+ ```json
91
+ {
92
+ "dependencies": {
93
+ "@tauri-apps/plugin-log": "^2.0.0"
94
+ }
95
+ }
96
+ ```
97
+
98
+ #### 2. Initialize Plugin (src/lib.rs)
99
+
100
+ ```rust
101
+ use tauri_plugin_log::{Target, TargetKind};
102
+
103
+ pub fn init<R: Runtime>() -> TauriPlugin<R> {
104
+ Builder::new("debug-tools")
105
+ .setup(|app, _api| {
106
+ app.handle().plugin(
107
+ tauri_plugin_log::Builder::new()
108
+ .targets([
109
+ Target::new(TargetKind::Stdout),
110
+ Target::new(TargetKind::LogDir {
111
+ file_name: Some("debug.log".to_string())
112
+ }),
113
+ Target::new(TargetKind::Webview),
114
+ ])
115
+ .max_file_size(50_000)
116
+ .build()
117
+ )?;
118
+ Ok(())
119
+ })
120
+ .build()
121
+ }
122
+ ```
123
+
124
+ #### 3. Update Frontend Code
125
+
126
+ **Replace**:
127
+
128
+ ```typescript
129
+ import { appendDebugLogs } from "tauri-plugin-debug-tools/consoleLogger";
130
+ await appendDebugLogs("Message");
131
+ ```
132
+
133
+ **With**:
134
+
135
+ ```typescript
136
+ import { logger } from "tauri-plugin-debug-tools/logAdapter";
137
+ logger.info("Message");
138
+ ```
139
+
140
+ #### 4. Update Permissions
141
+
142
+ **Before** (`permissions/default.toml`):
143
+
144
+ ```toml
145
+ permissions = [
146
+ "allow-append-debug-logs",
147
+ "allow-get-console-logs",
148
+ ]
149
+ ```
150
+
151
+ **After** (`permissions/debug-with-logging.toml`):
152
+
153
+ ```toml
154
+ permissions = [
155
+ "core:default",
156
+ "log:default",
157
+ ]
158
+ ```
159
+
160
+ #### 5. Update Log Retrieval
161
+
162
+ **Before**:
163
+
164
+ ```typescript
165
+ const logs = await getConsoleLogs();
166
+ console.log(logs.join("\n"));
167
+ ```
168
+
169
+ **After**:
170
+
171
+ ```bash
172
+ # Read from platform-specific location
173
+ cat ~/Library/Logs/{bundle_id}/debug.log # macOS
174
+ ```
175
+
176
+ Or use `analyze_logs.sh` script:
177
+
178
+ ```bash
179
+ ./scripts/analyze_logs.sh
180
+ ```
181
+
182
+ ## Phase 2: Screenshot Migration
183
+
184
+ ### Before (macOS screencapture)
185
+
186
+ ```bash
187
+ # scripts/capture.sh
188
+ screencapture -x -T 0 "$output_path"
189
+ ```
190
+
191
+ **Limitations**:
192
+
193
+ - macOS only
194
+ - Requires Screen Recording permission
195
+ - Shell script dependency
196
+
197
+ ### After (Official Plugin)
198
+
199
+ ```typescript
200
+ // guest-js/screenshotHelper.ts
201
+ import { captureMainWindow } from "tauri-plugin-debug-tools/screenshotHelper";
202
+
203
+ const imagePath = await captureMainWindow();
204
+ // Returns base64 PNG data
205
+ ```
206
+
207
+ **Benefits**:
208
+
209
+ - Cross-platform (macOS/Windows/Linux)
210
+ - No external dependencies
211
+ - Programmatic access from TypeScript
212
+
213
+ ### Migration Steps
214
+
215
+ #### 1. Add Dependencies
216
+
217
+ **Cargo.toml**:
218
+
219
+ ```toml
220
+ [dependencies]
221
+ tauri-plugin-screenshots = "2.0"
222
+ ```
223
+
224
+ **package.json**:
225
+
226
+ ```json
227
+ {
228
+ "dependencies": {
229
+ "tauri-plugin-screenshots-api": "^2.0.0"
230
+ }
231
+ }
232
+ ```
233
+
234
+ #### 2. Initialize Plugin (src/lib.rs)
235
+
236
+ ```rust
237
+ pub fn init<R: Runtime>() -> TauriPlugin<R> {
238
+ Builder::new("debug-tools")
239
+ .setup(|app, _api| {
240
+ app.handle().plugin(tauri_plugin_screenshots::init())?;
241
+ Ok(())
242
+ })
243
+ .build()
244
+ }
245
+ ```
246
+
247
+ #### 3. Update Frontend Code
248
+
249
+ **Replace**:
250
+
251
+ ```bash
252
+ TAURI_APP_NAME=myapp ./scripts/capture.sh
253
+ ```
254
+
255
+ **With**:
256
+
257
+ ```typescript
258
+ import { captureMainWindow } from "tauri-plugin-debug-tools/screenshotHelper";
259
+
260
+ const screenshot = await captureMainWindow();
261
+ if (screenshot) {
262
+ // screenshot is base64 PNG data
263
+ console.log("Screenshot captured");
264
+ }
265
+ ```
266
+
267
+ #### 4. Update Permissions
268
+
269
+ Add to capabilities:
270
+
271
+ ```json
272
+ {
273
+ "permissions": [
274
+ "screenshots:default"
275
+ ]
276
+ }
277
+ ```
278
+
279
+ ## Common Migration Patterns
280
+
281
+ ### Pattern 1: App Initialization
282
+
283
+ **Before**:
284
+
285
+ ```typescript
286
+ // No special initialization
287
+ ```
288
+
289
+ **After**:
290
+
291
+ ```typescript
292
+ import { logger } from "tauri-plugin-debug-tools/logAdapter";
293
+
294
+ async function initializeApp() {
295
+ const detach = await logger.initialize();
296
+
297
+ logger.info("App initialized");
298
+
299
+ // Store detach function for cleanup
300
+ window.addEventListener("beforeunload", () => detach());
301
+ }
302
+ ```
303
+
304
+ ### Pattern 2: Error Logging
305
+
306
+ **Before**:
307
+
308
+ ```typescript
309
+ import { appendDebugLogs } from "./consoleLogger";
310
+
311
+ try {
312
+ await riskyOperation();
313
+ } catch (error) {
314
+ await appendDebugLogs(`Error: ${error.message}`);
315
+ }
316
+ ```
317
+
318
+ **After**:
319
+
320
+ ```typescript
321
+ import { logger } from "tauri-plugin-debug-tools/logAdapter";
322
+
323
+ try {
324
+ await riskyOperation();
325
+ } catch (error) {
326
+ logger.error(`Error: ${error.message}`);
327
+ }
328
+ ```
329
+
330
+ ### Pattern 3: Debug Snapshot
331
+
332
+ **Before**:
333
+
334
+ ```typescript
335
+ import { writeDebugSnapshot } from "./debugBridge";
336
+
337
+ const logs = await getConsoleLogs();
338
+ await writeDebugSnapshot({
339
+ timestamp: new Date().toISOString(),
340
+ logs,
341
+ });
342
+ ```
343
+
344
+ **After**:
345
+
346
+ ```typescript
347
+ // Logs already persisted to file
348
+ // Use writeDebugSnapshot for additional metadata only
349
+ import { writeDebugSnapshot } from "./debugBridge";
350
+
351
+ await writeDebugSnapshot({
352
+ timestamp: new Date().toISOString(),
353
+ // No need to include logs - already in debug.log
354
+ });
355
+ ```
356
+
357
+ ## Rollback Strategy
358
+
359
+ If migration causes issues, follow these steps:
360
+
361
+ ### 1. Keep Old Implementation
362
+
363
+ Do not delete `consoleLogger.ts` until full validation:
364
+
365
+ ```typescript
366
+ // Temporarily support both
367
+ import { logger as newLogger } from "./logAdapter";
368
+ import { appendDebugLogs as oldLogger } from "./consoleLogger";
369
+
370
+ // Use feature flag
371
+ const useOfficialPlugin = import.meta.env.VITE_USE_OFFICIAL_LOG === "true";
372
+
373
+ export const logger = useOfficialPlugin ? newLogger : {
374
+ info: (msg) => oldLogger(msg),
375
+ error: (msg) => oldLogger(`ERROR: ${msg}`),
376
+ // ... other levels
377
+ };
378
+ ```
379
+
380
+ ### 2. Gradual Feature Flag Rollout
381
+
382
+ ```typescript
383
+ // Enable for specific environments
384
+ const ENABLE_OFFICIAL_PLUGINS = {
385
+ development: true,
386
+ staging: true,
387
+ production: false, // Keep false until validated
388
+ };
389
+
390
+ const usePlugins = ENABLE_OFFICIAL_PLUGINS[import.meta.env.MODE];
391
+ ```
392
+
393
+ ### 3. Monitoring & Validation
394
+
395
+ Before removing old implementation:
396
+
397
+ - [ ] Verify logs appear in expected platform-specific locations
398
+ - [ ] Confirm log rotation works (create 50KB+ logs)
399
+ - [ ] Test screenshot capture on all target platforms
400
+ - [ ] Validate permissions configuration
401
+ - [ ] Check error handling for plugin initialization failures
402
+
403
+ ## Breaking Changes
404
+
405
+ ### Log Format
406
+
407
+ **Before**: Plain strings in array
408
+
409
+ ```json
410
+ ["2024-01-01 12:00:00 - Message 1", "2024-01-01 12:00:01 - Message 2"]
411
+ ```
412
+
413
+ **After**: Structured log lines in file
414
+
415
+ ```
416
+ 2024-01-01T12:00:00.123Z INFO app_name: Message 1
417
+ 2024-01-01T12:00:01.456Z ERROR app_name: Message 2
418
+ ```
419
+
420
+ ### Log Access
421
+
422
+ **Before**: Synchronous in-memory access
423
+
424
+ ```typescript
425
+ const logs = await getConsoleLogs(); // Returns immediately
426
+ ```
427
+
428
+ **After**: File system access required
429
+
430
+ ```typescript
431
+ // Read from filesystem
432
+ import { readTextFile } from "@tauri-apps/plugin-fs";
433
+ import { appLogDir } from "@tauri-apps/api/path";
434
+
435
+ const logDir = await appLogDir();
436
+ const logs = await readTextFile(`${logDir}/debug.log`);
437
+ ```
438
+
439
+ ## Platform-Specific Considerations
440
+
441
+ ### macOS
442
+
443
+ - **Log Location**: `~/Library/Logs/{bundle_id}/debug.log`
444
+ - **Permissions**: No special permissions required for logging
445
+ - **Screenshots**: Works without Screen Recording permission (captures own windows)
446
+
447
+ ### Windows
448
+
449
+ - **Log Location**: `%LOCALAPPDATA%\{bundle_id}\logs\debug.log`
450
+ - **Permissions**: Standard file write permissions
451
+ - **Screenshots**: Works with standard permissions
452
+
453
+ ### Linux
454
+
455
+ - **Log Location**: `~/.local/share/{bundle_id}/logs/debug.log`
456
+ - **Permissions**: Standard file write permissions
457
+ - **Screenshots**: May require Wayland/X11 specific permissions
458
+
459
+ ## Validation Checklist
460
+
461
+ Before marking migration complete:
462
+
463
+ - [ ] Official plugins added to Cargo.toml and package.json
464
+ - [ ] Plugins initialized in src/lib.rs
465
+ - [ ] Permissions updated in capabilities
466
+ - [ ] Frontend code updated to use new APIs
467
+ - [ ] Log files created in correct platform-specific locations
468
+ - [ ] Log rotation tested (50KB threshold)
469
+ - [ ] Screenshots work on all target platforms
470
+ - [ ] Error handling tested (plugin init failures)
471
+ - [ ] Documentation updated
472
+ - [ ] Old implementation removed (or feature-flagged)
473
+
474
+ ## Support
475
+
476
+ For migration issues:
477
+
478
+ 1. Check [TROUBLESHOOTING.md](TROUBLESHOOTING.md) for common problems
479
+ 2. Review [LOGGING.md](LOGGING.md) for plugin configuration details
480
+ 3. See [SCREENSHOTS.md](SCREENSHOTS.md) for screenshot API usage
481
+ 4. Open issue on GitHub repository with migration context
482
+
483
+ ## References
484
+
485
+ - [tauri-plugin-log Documentation](https://v2.tauri.app/plugin/logging/)
486
+ - [tauri-plugin-screenshots Repository](https://github.com/ayangweb/tauri-plugin-screenshots)
487
+ - [Migration Plan](../../../../.claude/plans/shiny-knitting-squirrel.md)