Logs & Diagnostics
Log Locations
| Source | Location |
|---|---|
| Application logs | stdout/stderr (captured by PM2 or Docker) |
| PM2 logs | ~/.pm2/logs/zs-iot-*.log |
| SQLite logs | Stored in the database logs table |
| Device logs | Per-device communication logs in the database |
Viewing Logs
# PM2 logs
pm2 logs zs-iot
# Follow logs in real-time
pm2 logs zs-iot --lines 100
# View device-specific logs via API
curl http://localhost:3000/api/logs?device_id=ada-xxxxx
Common Log Patterns
| Pattern | Meaning |
|---|---|
[PING] Device ada-xxx OK (120ms) | Healthy device response |
[PING] Device ada-xxx FAILED (timeout) | Device unreachable |
[ACTION] unlock ada-xxx SUCCESS | Device action completed |
[WEBHOOK] booking.start received | Booking event received |
[TAILSCALE] Connected to network | VPN connection established |
Diagnostics
Check System Health
curl http://localhost:3000/api/health
Check Individual Device
curl http://localhost:3000/api/devices/ada-xxxxx/status
Test Device Connection
curl -X POST http://localhost:3000/api/devices/ada-xxxxx/ping