Silence httpx request logs, log favicon fetches in one line
This commit is contained in:
+16
-3
@@ -31,6 +31,10 @@ from pagerite.state import SITE_URL, _html_response, analytics_store
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# httpx logs every request at INFO (e.g. the favicon fetches below); our own
|
||||||
|
# one-line summary in _schedule_favicon_fetch replaces that noise.
|
||||||
|
logging.getLogger("httpx").setLevel(logging.WARNING)
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
# Live WebSocket clients for the analytics stream.
|
# Live WebSocket clients for the analytics stream.
|
||||||
@@ -253,9 +257,18 @@ async def _fetch_favicon(origin: str) -> None:
|
|||||||
|
|
||||||
def _schedule_favicon_fetch() -> None:
|
def _schedule_favicon_fetch() -> None:
|
||||||
"""Start background favicon fetches for origins that need one."""
|
"""Start background favicon fetches for origins that need one."""
|
||||||
for origin in analytics_store.favicon_origins_needed():
|
origins = [
|
||||||
if origin in _favicon_in_flight:
|
origin
|
||||||
continue
|
for origin in analytics_store.favicon_origins_needed()
|
||||||
|
if origin not in _favicon_in_flight
|
||||||
|
]
|
||||||
|
if not origins:
|
||||||
|
return
|
||||||
|
logger.info(
|
||||||
|
"Fetching favicons: %s",
|
||||||
|
", ".join(o.removeprefix("https://") for o in origins),
|
||||||
|
)
|
||||||
|
for origin in origins:
|
||||||
_favicon_in_flight.add(origin)
|
_favicon_in_flight.add(origin)
|
||||||
asyncio.create_task(_fetch_favicon(origin))
|
asyncio.create_task(_fetch_favicon(origin))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user