Skip to content

Prune stale log files on startup#24

Merged
timhartmann7 merged 2 commits into
mainfrom
feat/prune-old-logs
May 29, 2026
Merged

Prune stale log files on startup#24
timhartmann7 merged 2 commits into
mainfrom
feat/prune-old-logs

Conversation

@timhartmann7
Copy link
Copy Markdown
Owner

The daily rolling appender creates one omnyssh.log.YYYY-MM-DD file per day in the config directory and never cleans them up, so logs accumulate indefinitely and fill the disk over time.

This adds cleanup_old_logs, which runs once at startup and removes rolling log files older than 7 days. It is:

  • Cross-platform. Operates on dirs::config_dir()/omnyssh, the same directory used on macOS, Linux, Termux, and Windows. Age is read from filesystem mtime, so the logic is identical everywhere.
  • Fault-tolerant. A missing directory, unreadable entry, or failed delete is skipped rather than propagated, so cleanup can never block startup.
  • Safe. Only files prefixed with omnyssh.log are considered; config.toml, hosts.toml, and snippets.toml are never touched.

Covered by 4 integration tests: old files removed, recent files kept, non-log files untouched, and missing directory is a no-op.

@timhartmann7 timhartmann7 merged commit 1319ea5 into main May 29, 2026
3 checks passed
@timhartmann7 timhartmann7 deleted the feat/prune-old-logs branch May 29, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant