local-web-search/services/orchestrator/app/logging_setup.py
User e2b329b2bb M1: scrape spine — renderer, extractor, orchestrator /scrape, compose, health, render cache
- renderer: Node/Playwright, single browser + pooled contexts with concurrency
  cap and FIFO queue, Redis render cache (graceful no-op without Redis)
- extractor: FastAPI + Trafilatura, HTML -> {title, text, metadata}
- orchestrator: /scrape (render -> extract) with per-stage trace, aggregated
  /health, structured JSON logging on all services
- docker-compose for orchestrator/renderer/extractor/redis with healthchecks

Verified locally: end-to-end scrape of example.com and Wikipedia; error paths
for unreachable hosts and bad schemes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-05 22:02:38 -07:00

22 lines
618 B
Python

import json
import logging
import sys
class JsonFormatter(logging.Formatter):
def format(self, record: logging.LogRecord) -> str:
return json.dumps(
{
"ts": self.formatTime(record),
"level": record.levelname.lower(),
"service": "orchestrator",
"msg": record.getMessage(),
}
)
def setup() -> logging.Logger:
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(JsonFormatter())
logging.basicConfig(level=logging.INFO, handlers=[handler])
return logging.getLogger("orchestrator")