feat: add logging config generator script (refs #81)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 3m41s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 31s
Deploy to Staging / Verify Staging (pull_request) Successful in 2m19s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped

Create generate-log-config.sh that maps a single LOG_LEVEL env var to
per-container settings for Backend, Frontend, PostgreSQL, Redis, and
Traefik. Script validates input and generates .env.logging file.

Integrate script into staging and production CI/CD pipelines.
Remove obsolete SPRINTS.md calendar file.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Eric Gullickson
2026-02-03 19:25:36 -06:00
parent b226ca59de
commit da406d9538
5 changed files with 84 additions and 36 deletions

View File

@@ -0,0 +1,69 @@
#!/bin/bash
# generate-log-config.sh - Generate .env.logging from LOG_LEVEL
# Maps a single LOG_LEVEL environment variable to per-container settings
#
# Usage: ./generate-log-config.sh [LOG_LEVEL]
# LOG_LEVEL: DEBUG, INFO, WARN, or ERROR (default: INFO)
#
# Output: Creates .env.logging file with container-specific log settings
#
# Exit codes:
# 0 - Configuration generated successfully
# 1 - Invalid LOG_LEVEL provided
set -euo pipefail
LOG_LEVEL="${1:-INFO}"
# Validate input
case "$LOG_LEVEL" in
DEBUG|INFO|WARN|ERROR) ;;
*)
echo "Error: Invalid LOG_LEVEL '$LOG_LEVEL'. Must be DEBUG, INFO, WARN, or ERROR." >&2
exit 1
;;
esac
# Convert to lowercase for services that need it
LOG_LEVEL_LOWER=$(echo "$LOG_LEVEL" | tr '[:upper:]' '[:lower:]')
# Map PostgreSQL log settings based on level
case "$LOG_LEVEL" in
DEBUG) POSTGRES_LOG_STATEMENT="all"; POSTGRES_LOG_MIN_DURATION="0" ;;
INFO) POSTGRES_LOG_STATEMENT="ddl"; POSTGRES_LOG_MIN_DURATION="500" ;;
WARN) POSTGRES_LOG_STATEMENT="none"; POSTGRES_LOG_MIN_DURATION="1000" ;;
ERROR) POSTGRES_LOG_STATEMENT="none"; POSTGRES_LOG_MIN_DURATION="-1" ;;
esac
# Map Redis log level
case "$LOG_LEVEL" in
DEBUG) REDIS_LOGLEVEL="debug" ;;
INFO) REDIS_LOGLEVEL="verbose" ;;
WARN) REDIS_LOGLEVEL="notice" ;;
ERROR) REDIS_LOGLEVEL="warning" ;;
esac
# Generate .env.logging file
cat > .env.logging << EOF
# Generated by generate-log-config.sh - DO NOT EDIT MANUALLY
# Regenerate with: ./scripts/ci/generate-log-config.sh $LOG_LEVEL
LOG_LEVEL=$LOG_LEVEL
# Backend/OCR (Pino)
BACKEND_LOG_LEVEL=$LOG_LEVEL_LOWER
# Frontend (Vite)
VITE_LOG_LEVEL=$LOG_LEVEL_LOWER
# PostgreSQL
POSTGRES_LOG_STATEMENT=$POSTGRES_LOG_STATEMENT
POSTGRES_LOG_MIN_DURATION=$POSTGRES_LOG_MIN_DURATION
# Redis
REDIS_LOGLEVEL=$REDIS_LOGLEVEL
# Traefik
TRAEFIK_LOG_LEVEL=$LOG_LEVEL
EOF
echo "Generated .env.logging with LOG_LEVEL=$LOG_LEVEL"