api-client/packages/hoppscotch-desktop/src-tauri
Shreyas fbeb0e56be
feat(desktop): file-based logs with rotation (#5009)
This PR adds a file-based logging system with size-based rotation to the desktop application. It essentially redirects existing diagnostic to size-based rotating files for troubleshooting environment-specific issues.

Closes HFE-801

The desktop application currently lacks a persistent logging mechanism in production environments. Logs are only available through the development mode console.

This PR will help diagnose issues reported in #4859, #4950, #5003, discussions #4984 and #4986.

Mainly aiming to understand errors in specific environments that can't be reproduced in our testing setups.

This implementation uses the tracing ecosystem (`tracing`, `tracing_subscriber`, `tracing_appender`) along with `file_rotate` to create log files in the platform's log directory. The logs are automatically rotated when they reach `10MB`, with a maximum of `5` files retained.

Thinking 10 * 5 MB is reasonable disk usage while maintaining sufficient history.

The system currently writes to both the console (with ANSI colors where supported) and to files (without ANSI formatting for readability). Log levels are currently controlled via the `RUST_LOG` environment variable, defaulting to "debug" when not specified.

| OS      | Log File Path                                        |
|---------|------------------------------------------------------|
| Windows | `C:\Users\<username>\AppData\Local\io.hoppscotch.desktop\logs\io.hoppscotch.desktop.log` |
| macOS   | `~/Library/Logs/io.hoppscotch.desktop/io.hoppscotch.desktop.log` |
| Linux   | `~/.local/share/io.hoppscotch.desktop/logs/io.hoppscotch.desktop.log` |
2025-04-25 17:09:51 +05:30
..
capabilities feat(desktop): stablize updater ux and window state (#4798) 2025-03-03 15:00:04 +05:30
icons feat: platform independent core and the new desktop app (#4684) 2025-02-28 00:01:25 +05:30
src feat(desktop): file-based logs with rotation (#5009) 2025-04-25 17:09:51 +05:30
.gitignore feat: platform independent core and the new desktop app (#4684) 2025-02-28 00:01:25 +05:30
build.rs feat: platform independent core and the new desktop app (#4684) 2025-02-28 00:01:25 +05:30
Cargo.lock feat(desktop): file-based logs with rotation (#5009) 2025-04-25 17:09:51 +05:30
Cargo.toml feat(desktop): file-based logs with rotation (#5009) 2025-04-25 17:09:51 +05:30
tauri.conf.json chore: bump version to 2025.3.2 2025-04-15 13:16:56 +05:30