Files
schwab-mcp-custom/schwab_scraper/utils/logging.py
b3nw 650ea2d087
All checks were successful
Build and Push Docker Image / build (push) Successful in 34s
Fix build: Bundle schwab_scraper source and use local dependencies
2026-04-24 01:50:20 +00:00

20 lines
699 B
Python

import logging
import os
from datetime import datetime, timezone
def setup_logging(debug: bool = False) -> None:
level = logging.DEBUG if debug else logging.INFO
logging.basicConfig(level=level, format='%(asctime)s %(levelname)s %(name)s: %(message)s')
def save_debug_artifact(filename: str, content: str | bytes) -> str:
debug_dir = "debug"
os.makedirs(debug_dir, exist_ok=True)
timestamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
path = os.path.join(debug_dir, f"{timestamp}_{filename}")
mode = 'wb' if isinstance(content, (bytes, bytearray)) else 'w'
with open(path, mode) as f:
f.write(content) # type: ignore[arg-type]
return path