Devang1290
feat: deploy News Whisper on-demand search API (FastAPI + Docker)
2cb327c
"""
Terminal Colors & Logging Utilities
====================================
Provides ANSI color codes and a simple structured logger used across all
backend modules (web scraping, summarization, TTS, and the main CLI).
Usage:
from backend.common.colors import Colors, Log
Log.info("Processing article...")
Log.success("Done!")
Log.error("Something went wrong")
Log.header("PIPELINE START")
Log.section("Step 1: Scraping")
"""
class Colors:
"""ANSI escape codes for terminal coloring."""
BLUE = '\033[94m'
CYAN = '\033[96m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
RESET = '\033[0m'
BOLD = '\033[1m'
DIM = '\033[2m'
MAGENTA = '\033[95m'
class Log:
"""Simple structured logger that prints colored messages to stdout."""
@staticmethod
def header(msg):
"""Print a prominent header (used for pipeline start/end)."""
print(f"\n{Colors.BOLD}{Colors.CYAN}{'=' * 80}{Colors.RESET}")
print(f"{Colors.BOLD}{Colors.CYAN}{msg}{Colors.RESET}")
print(f"{Colors.BOLD}{Colors.CYAN}{'=' * 80}{Colors.RESET}\n")
@staticmethod
def section(msg):
"""Print a section divider (used for pipeline steps)."""
print(f"\n{Colors.BOLD}{Colors.MAGENTA}=> {msg}{Colors.RESET}\n")
@staticmethod
def info(msg):
print(f"{Colors.BLUE}[INFO]{Colors.RESET} {msg}")
@staticmethod
def success(msg):
print(f"{Colors.GREEN}[SUCCESS]{Colors.RESET} {msg}")
@staticmethod
def warning(msg):
print(f"{Colors.YELLOW}[WARNING]{Colors.RESET} {msg}")
@staticmethod
def error(msg):
print(f"{Colors.RED}[ERROR]{Colors.RESET} {msg}")