Spaces:
Sleeping
Sleeping
| """ | |
| 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.""" | |
| 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") | |
| def section(msg): | |
| """Print a section divider (used for pipeline steps).""" | |
| print(f"\n{Colors.BOLD}{Colors.MAGENTA}=> {msg}{Colors.RESET}\n") | |
| def info(msg): | |
| print(f"{Colors.BLUE}[INFO]{Colors.RESET} {msg}") | |
| def success(msg): | |
| print(f"{Colors.GREEN}[SUCCESS]{Colors.RESET} {msg}") | |
| def warning(msg): | |
| print(f"{Colors.YELLOW}[WARNING]{Colors.RESET} {msg}") | |
| def error(msg): | |
| print(f"{Colors.RED}[ERROR]{Colors.RESET} {msg}") | |