logs: standardise log filenames to xamxam-{service}-{date}.log

This commit is contained in:
Pontoporeia
2026-08-24 11:34:34 +02:00
parent 7b6d79c133
commit d2cef85966
25 changed files with 442 additions and 83 deletions
+3 -3
View File
@@ -153,12 +153,12 @@
- [ ] Add hourly and daily jobs:
```cron
# Hourly snapshot — kept 30 days
0 * * * * /usr/local/bin/backup-sqlite.sh >> /var/log/sqlite-backup.log 2>&1
0 * * * * /usr/local/bin/backup-sqlite.sh >> /var/log/xamxam-backup-$(date +%Y-%m-%d).log 2>&1
# Daily snapshot at 2am — kept 90 days
0 2 * * * RETENTION_DAYS=90 /usr/local/bin/backup-sqlite.sh >> /var/log/sqlite-backup.log 2>&1
0 2 * * * RETENTION_DAYS=90 /usr/local/bin/backup-sqlite.sh >> /var/log/xamxam-backup-$(date +%Y-%m-%d).log 2>&1
```
- [ ] Verify the log after the next hour: `tail -f /var/log/sqlite-backup.log`
- [ ] Verify the log after the next hour: `tail -f /var/log/xamxam-backup-$(date +%Y-%m-%d).log`
---
+10 -4
View File
@@ -55,8 +55,14 @@ just deploy-all-first # deploy + deploy-backup + deploy-cleanup-cron
| `just deploy-db` | Push local `xamxam.db` → remote (**refuses** if a remote DB already exists) |
| `just deploy-verify-permissions` | Check ownership / permissions on the server |
> ℹ️ **First deploy?** After `just deploy`, run `just deploy-backup` to install
> the backup script + cron jobs.
> ℹ️ **First deploy?** After `just deploy`, run `just deploy-backup` and
> `just deploy-cleanup-cron` to install the backup/cleanup cron jobs, and
> `just deploy-logrotate` to install log rotation. A single `just deploy-all-first`
> chains all of these together.
> The app log directory `/var/log/xamxam/` is provisioned automatically by
> `deploy-code` on every run (via `deploy-server.sh`), so no separate step is
> needed for it. To migrate logs written by an older build, run
> `just migrate-log-names --apply` once.
### Environment file & re-encryption
@@ -81,7 +87,7 @@ gzipped to `/var/backups/xamxam/` on the server.
| `just deploy-backup` | Install backup script + cron jobs (one-shot) |
| `just deploy-backup-script` | Install `/usr/local/bin/backup-sqlite.sh` |
| `just deploy-backup-cron` | Install `/etc/cron.d/xamxam-backup` (hourly 30d + daily 90d) + dirs/log |
| `just deploy-check-backup-log` | Tail `/var/log/sqlite-backup.log` |
| `just deploy-check-backup-log` | Tail `/var/log/xamxam-backup-YYYY-MM-DD.log` |
| `just deploy-list-backups` | List backups on the server |
| `just trigger-backup` | Run the backup script now |
| `just test-restore <path.gz>` | Fetch + decompress + verify a remote snapshot |
@@ -91,7 +97,7 @@ Backup files: `/var/backups/xamxam/db-<timestamp>.db.gz`.
Draft cleanup is handled by a separate cron (`/etc/cron.d/xamxam-cleanup`),
installed via `just deploy-cleanup-cron`, logging to
`/var/log/xamxam-cleanup.log`. Verify with `just deploy-check-cleanup-log`.
`/var/log/xamxam-cleanup-YYYY-MM-DD.log`. Verify with `just deploy-check-cleanup-log`.
---
+2 -2
View File
@@ -45,7 +45,7 @@ Do not replace any existing class yet. Just build the foundation.
```
Each channel gets:
- A `RotatingFileHandler` writing to `storage/logs/{channel}.log`, keeping 30 days
- A `RotatingFileHandler` writing to `xamxam-{channel}.log` (production: `/var/log/xamxam/`; dev: `storage/logs/`), keeping 30 days
- A `JsonFormatter` so log lines stay JSON (preserving the existing format contract)
- Log level set from an environment variable (`LOG_LEVEL`, defaulting to `WARNING` in production, `DEBUG` in dev)
@@ -58,7 +58,7 @@ one file at a time without passing instances around.
- Rewrite `AppLogger` as a thin wrapper that delegates to `Logger::get('app')`
- Keep the existing public method signatures identical — no call sites change in this step
- Run the app, verify log output appears in `storage/logs/app.log`
- Run the app, verify log output appears in `xamxam-app.log` (see the log dir for the active SAPI)
- Delete the old file-writing implementation inside `AppLogger`, keep the class as a facade for now
---
+2 -1
View File
@@ -59,7 +59,8 @@ spoofing.
files. The DocumentRoot is `app/public/` only.
- Restricted-file downloads are gated by a request/approval/token flow
(`file_access_*` tables).
- Logs write to `app/storage/logs/` — outside the webroot, not publicly served.
- Logs write to `/var/log/xamxam/` in production (and `app/storage/logs/`
only in dev/cli-server) — outside the webroot, not publicly served.
## Injection & output