#!/usr/bin/env bash set -e # ============================================================================== # Plane Interactive Log Diagnostics Tool # Target directory: /home/ubuntu/plane # ============================================================================== cd /home/ubuntu/plane 2>/dev/null || cd "$(dirname "$0")" ACTION="${1:-help}" case "$ACTION" in all) echo "==> Streaming ALL live container logs (Ctrl+C to stop)..." docker compose logs -f --tail=50 ;; backend|api) echo "==> Streaming Backend API logs (Every Request, Status, User Action & DB Event)..." if [ -f "logs/api/plane-requests.log" ]; then echo "--- Following logs/api/plane-requests.log + logs/api/plane-app.log ---" tail -f -n 50 logs/api/plane-requests.log logs/api/plane-app.log 2>/dev/null || tail -f -n 50 logs/api/plane-requests.log else docker compose logs -f --tail=50 api fi ;; frontend|web) echo "==> Streaming Frontend Web & Access logs..." if [ -f "logs/web/web-access.log" ]; then echo "--- Following logs/web/web-access.log ---" tail -f -n 50 logs/web/web-access.log else docker compose logs -f --tail=50 web fi ;; client) echo "==> Streaming Frontend Client-Side Browser Logs (Errors, Unhandled Rejections, UI Events)..." if [ -f "logs/api/plane-client.log" ]; then echo "--- Following logs/api/plane-client.log ---" tail -f -n 50 logs/api/plane-client.log else echo "Waiting for client-side events in logs/api/plane-client.log..." touch logs/api/plane-client.log 2>/dev/null || true tail -f -n 50 logs/api/plane-client.log 2>/dev/null || docker compose logs -f --tail=50 api | grep "plane.client" fi ;; error|errors) echo "==> Streaming error logs..." if [ -f "logs/api/plane-error.log" ]; then echo "--- Persistent error log file: logs/api/plane-error.log ---" tail -f -n 50 logs/api/plane-error.log else docker compose logs -f --tail=50 api | grep -iE "error|exception|traceback|fail|500|502" fi ;; proxy) echo "==> Streaming Proxy logs..." if [ -f "logs/proxy/proxy-access.log" ]; then tail -f -n 50 logs/proxy/proxy-access.log else docker compose logs -f --tail=50 proxy fi ;; worker) echo "==> Streaming Celery worker background task logs..." docker compose logs -f --tail=50 worker beat-worker ;; files|list) echo "==> Persistent log files on host ($(pwd)/logs):" find logs -type f -exec ls -lh {} + 2>/dev/null || echo "No persistent log files found yet." ;; tail) TARGET="${2:-api}" echo "==> Tailing container $TARGET..." docker compose logs -f --tail=100 "$TARGET" ;; help|*) echo "==========================================================" echo " Plane Log & Action Diagnostics Tool" echo "==========================================================" echo "Usage:" echo " ./logs.sh frontend - Stream frontend web access & static bundle logs" echo " ./logs.sh backend - Stream backend API request & action logs" echo " ./logs.sh client - Stream browser-side frontend JS errors & crashes" echo " ./logs.sh error - Stream all error stacktraces and exceptions" echo " ./logs.sh proxy - Stream Caddy reverse proxy ingress logs" echo " ./logs.sh worker - Stream background Celery workers" echo " ./logs.sh all - Stream logs from all Plane containers simultaneously" echo " ./logs.sh files - List all persistent log files on server disk" echo " ./logs.sh tail - Tail a specific docker service (e.g. ./logs.sh tail api)" echo "==========================================================" ;; esac