mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #5147] [MERGED] feat(agent): file-based logs with rotation #5077
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5077
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5147
Author: @CuriousCorrelation
Created: 6/13/2025
Status: ✅ Merged
Merged: 6/13/2025
Merged by: @AndrewBastin
Base:
patch← Head:feat-agent-file-based-rotating-logs📝 Commits (1)
59337dafeat(agent): file-based logs with rotation📊 Changes
8 files changed (+122 additions, -64 deletions)
View changed files
📝
packages/hoppscotch-agent/src-tauri/Cargo.lock(+13 -1)📝
packages/hoppscotch-agent/src-tauri/Cargo.toml(+2 -0)📝
packages/hoppscotch-agent/src-tauri/src/error.rs(+7 -1)📝
packages/hoppscotch-agent/src-tauri/src/lib.rs(+4 -48)➕
packages/hoppscotch-agent/src-tauri/src/logger.rs(+53 -0)📝
packages/hoppscotch-agent/src-tauri/src/main.rs(+38 -8)📝
packages/hoppscotch-agent/src-tauri/src/tray.rs(+3 -4)📝
packages/hoppscotch-desktop/src-tauri/src/logger.rs(+2 -2)📄 Description
This adds a file-based logging system with size-based rotation to the Hoppscotch Agent.
It essentially redirects existing diagnostic to size-based rotating files for troubleshooting environment-specific issues.
Closes HFE-897
Agent currently lacks a persistent logging mechanism in production environments. Logs are only available through the development mode console. 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 withfile_rotateto 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 MBjust like the desktop app 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 in
devmode are currently controlled via theRUST_LOGenvironment variable, defaulting to "debug" when not specified.C:\Users\<username>\AppData\Local\io.hoppscotch.agent\logs\io.hoppscotch.agent.log~/Library/Logs/io.hoppscotch.agent/io.hoppscotch.agent.log~/.local/share/io.hoppscotch.agent/logs/io.hoppscotch.agent.logNotes to reviewers
About setting up logging in
mainMoved
setup_loggingfunction fromlib.rsto its own module inlogger.rsto make sure it starts up before any plugins are initialized, which means we can control when the global default trace dispatcher is setup. Logger setup call inlib.rs(where it used to be commented out) would actually setup two dispatcher, eventually failing with panic:The current setup avoids that and also lets the logger collect startup logs.
Testing
We need to make sure:
~/Library/Logs/io.hoppscotch.agent/io.hoppscotch.agent.logon MacOS🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.