Add structured daemon lifecycle logs

VM start, image build, and network/setup failures were hard to diagnose because bangerd emitted almost no lifecycle logs and the Firecracker SDK logger was discarded. This adds a daemon-wide JSON logger with configurable log level so failures leave breadcrumbs instead of only side effects.

Log the main daemon and VM lifecycle stages, preserve raw Firecracker and image-build helper output in dedicated files, and include those log paths in daemon status and returned errors. Bridge SDK logrus output into the daemon logger at debug level so low-level Firecracker diagnostics are available without making normal info logs unreadable.

Validation: go test ./... and make build. Left unrelated worktree changes out of this commit, including internal/api/types.go, the deleted shell scripts, and my-rootfs.ext4.
This commit is contained in:
Thales Maciel 2026-03-16 16:16:28 -03:00
parent 5018bc6170
commit 644e60d739
No known key found for this signature in database
GPG key ID: 33112E6833C34679
13 changed files with 746 additions and 31 deletions

View file

@ -106,6 +106,9 @@ banger daemon socket
banger daemon stop
```
`banger daemon status` prints the daemon PID, socket path, and `bangerd.log`
location.
State lives under XDG directories:
- config: `~/.config/banger`
- state: `~/.local/state/banger`
@ -121,6 +124,7 @@ repo-built `./banger`. You can override either with `runtime_dir` in
`BANGER_MAPDNS_DATA_FILE`.
Useful config keys:
- `log_level`
- `runtime_dir`
- `firecracker_bin`
- `mapdns_bin`
@ -135,6 +139,15 @@ Useful config keys:
- `default_modules_dir`
- `default_packages_file`
## Logs
- daemon lifecycle logs: `~/.local/state/banger/bangerd.log`
- raw Firecracker output per VM: `~/.local/state/banger/vms/<vm-id>/firecracker.log`
- raw image-build helper output: `~/.local/state/banger/image-build/*.log`
`bangerd.log` is structured JSON. Set `log_level` in
`~/.config/banger/config.toml` or `BANGER_LOG_LEVEL` to one of `debug`,
`info`, `warn`, or `error`.
## Images
List images:
```bash