feat: proper logging architecture — Docker rotation, persisted service logs, verbosity config

docker-compose.yml:
- Add json-file logging driver (max-size: 10m, max-file: 5) to all 13 containers
- Docker now owns container stdout/stderr rotation automatically
- Add ./data/logs:/app/api/data/logs volume to API — service logs now persist across restarts

log_manager.py:
- Remove container log collection hack (Docker handles it natively)
- Add set_service_level(service, level) — change log level at runtime without restart
- Add get_service_levels() — return current per-service levels
- Simplify get_all_log_file_infos to return only service log files

app.py:
- Add GET /api/logs/verbosity — return current per-service log levels
- Add PUT /api/logs/verbosity — update levels at runtime, persist to config/log_levels.json
- Load persisted log level overrides at startup from log_levels.json
- Simplify rotate endpoint (service logs only, container logs owned by Docker)

wireguard_manager.py:
- get_keys(): return empty strings if key files don't exist (prevents get_status crash
  when wg0.conf is missing at startup and falls through to generate_config)

Logs page (4 tabs):
- API Service Logs: structured JSON logs from Python managers, with search/filter/rotate panel
- Container Logs: live docker logs (read via existing /api/containers/<name>/logs endpoint)
- Verbosity Config: per-service level dropdowns, apply immediately + persist
- Health History: existing health poll table

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 02:07:57 -04:00
parent 7b39331417
commit f848a1d056
6 changed files with 313 additions and 289 deletions
+61
View File
@@ -18,6 +18,11 @@ services:
networks:
cell-network:
ipv4_address: 172.20.0.2
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# DNS Server - CoreDNS for .cell TLD resolution
dns:
@@ -34,6 +39,11 @@ services:
networks:
cell-network:
ipv4_address: 172.20.0.3
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# DHCP Server - dnsmasq for IP leasing
dhcp:
@@ -51,6 +61,11 @@ services:
command: ["/bin/sh", "-c", "apk add --no-cache dnsmasq && dnsmasq -d -C /etc/dnsmasq.conf"]
cap_add:
- NET_ADMIN
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# NTP Server - chrony for time synchronization
ntp:
@@ -67,6 +82,11 @@ services:
cap_add:
- SYS_TIME
command: ["/bin/sh", "-c", "apk add --no-cache chrony && rm -f /var/run/chrony/chronyd.pid && exec chronyd -d -f /etc/chrony/chrony.conf -n"]
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# Email Server - Postfix + Dovecot
mail:
@@ -91,6 +111,11 @@ services:
ipv4_address: 172.20.0.6
cap_add:
- NET_ADMIN
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# Calendar & Contacts - Radicale
radicale:
@@ -105,6 +130,11 @@ services:
networks:
cell-network:
ipv4_address: 172.20.0.7
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# File Storage - WebDAV
webdav:
@@ -122,6 +152,11 @@ services:
networks:
cell-network:
ipv4_address: 172.20.0.8
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# WireGuard VPN
wireguard:
@@ -146,6 +181,11 @@ services:
sysctls:
- net.ipv4.conf.all.src_valid_mark=1
- net.ipv4.ip_forward=1
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# API Server
api:
@@ -159,6 +199,7 @@ services:
- ./config/api:/app/config
- ./config/wireguard:/app/config/wireguard
- ./config/dns:/app/config/dns
- ./data/logs:/app/api/data/logs
- /var/run/docker.sock:/var/run/docker.sock
pid: host
restart: unless-stopped
@@ -168,6 +209,11 @@ services:
depends_on:
- wireguard
- dns
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# Web UI - React + Vite
webui:
@@ -179,6 +225,11 @@ services:
networks:
cell-network:
ipv4_address: 172.20.0.11
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# Webmail - RainLoop
rainloop:
@@ -192,6 +243,11 @@ services:
- "8888:8888"
volumes:
- ./data/rainloop:/rainloop/data
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# File Manager - FileGator
filegator:
@@ -205,6 +261,11 @@ services:
- "8082:8080"
volumes:
- ./data/filegator:/var/www/filegator/private
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
networks:
cell-network: