[PR #5009] [MERGED] feat(desktop): file-based logs with rotation #5017

Closed
opened 2026-03-17 02:30:17 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5009
Author: @CuriousCorrelation
Created: 4/21/2025
Status: Merged
Merged: 4/25/2025
Merged by: @AndrewBastin

Base: nextHead: feat-desktop-log-rotation


📝 Commits (1)

  • 8a8891d feat(desktop): file-based logs with rotation

📊 Changes

5 files changed (+111 additions, -105 deletions)

View changed files

📝 packages/hoppscotch-desktop/src-tauri/Cargo.lock (+41 -91)
📝 packages/hoppscotch-desktop/src-tauri/Cargo.toml (+2 -0)
📝 packages/hoppscotch-desktop/src-tauri/src/lib.rs (+15 -2)
packages/hoppscotch-desktop/src-tauri/src/logger.rs (+52 -0)
📝 packages/hoppscotch-desktop/src-tauri/src/main.rs (+1 -12)

📄 Description

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.

image

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5009 **Author:** [@CuriousCorrelation](https://github.com/CuriousCorrelation) **Created:** 4/21/2025 **Status:** ✅ Merged **Merged:** 4/25/2025 **Merged by:** [@AndrewBastin](https://github.com/AndrewBastin) **Base:** `next` ← **Head:** `feat-desktop-log-rotation` --- ### 📝 Commits (1) - [`8a8891d`](https://github.com/hoppscotch/hoppscotch/commit/8a8891de2fc8753d163841c07941346969140f6c) feat(desktop): file-based logs with rotation ### 📊 Changes **5 files changed** (+111 additions, -105 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-desktop/src-tauri/Cargo.lock` (+41 -91) 📝 `packages/hoppscotch-desktop/src-tauri/Cargo.toml` (+2 -0) 📝 `packages/hoppscotch-desktop/src-tauri/src/lib.rs` (+15 -2) ➕ `packages/hoppscotch-desktop/src-tauri/src/logger.rs` (+52 -0) 📝 `packages/hoppscotch-desktop/src-tauri/src/main.rs` (+1 -12) </details> ### 📄 Description 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. ![image](https://github.com/user-attachments/assets/119f9909-428d-4964-936b-c3c0f452430f) 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` | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:30:17 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5017
No description provided.