Add automatic log rotation for daemon (bd-154)

- Integrated lumberjack library for production-ready log rotation
- Configurable via env vars: BEADS_DAEMON_LOG_MAX_SIZE, BEADS_DAEMON_LOG_MAX_BACKUPS, BEADS_DAEMON_LOG_MAX_AGE, BEADS_DAEMON_LOG_COMPRESS
- Defaults: 10MB max size, 3 backups, 7 day retention, compression enabled
- Added comprehensive tests for env var parsing and rotation config
- Updated README.md and CHANGELOG.md with rotation documentation
- Prevents unbounded log growth for long-running daemons

Amp-Thread-ID: https://ampcode.com/threads/T-8232d41a-6872-4f4c-962c-7fae8f5e83b7
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-18 16:30:19 -07:00
parent 8f80dde0ad
commit cff10b1998
7 changed files with 179 additions and 7 deletions
+9 -1
View File
@@ -915,7 +915,7 @@ The daemon will:
- Auto-push commits (if `--auto-push` flag set)
- Pull remote changes periodically
- Auto-import when remote changes detected
- Log all activity to `.beads/daemon.log`
- Log all activity to `.beads/daemon.log` with automatic rotation
Options:
```bash
@@ -929,6 +929,14 @@ bd daemon --global # Run as global daemon (see below)
bd daemon --migrate-to-global # Migrate from local to global daemon
```
Log rotation is automatic and configurable via environment variables:
```bash
export BEADS_DAEMON_LOG_MAX_SIZE=10 # Max log size in MB (default: 10)
export BEADS_DAEMON_LOG_MAX_BACKUPS=3 # Number of rotated logs to keep (default: 3)
export BEADS_DAEMON_LOG_MAX_AGE=7 # Max age of logs in days (default: 7)
export BEADS_DAEMON_LOG_COMPRESS=true # Compress rotated logs (default: true)
```
The daemon is ideal for:
- Always-on development machines
- Multi-agent workflows where agents need continuous sync