Add debug logging to page registry pipeline

Server-side: log page count, output size, and first 200 chars in _build_pages_sx.
Client-side: log script tag count, text length, parsed entry count in processPageScripts.
Helps diagnose why pages: 0 routes loaded.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 21:31:53 +00:00
parent f08bd403de
commit c80b5d674f
3 changed files with 23 additions and 5 deletions

View File

@@ -646,11 +646,15 @@ def _build_pages_sx(service: str) -> str:
``parse`` function. Each dict has keys: name, path, auth, has-data,
content, closure.
"""
import logging
_log = logging.getLogger("sx.pages")
from .pages import get_all_pages
from .parser import serialize as sx_serialize
pages = get_all_pages(service)
_log.debug("_build_pages_sx(%s): %d pages in registry", service, len(pages))
if not pages:
_log.warning("_build_pages_sx(%s): no pages found — page registry will be empty", service)
return ""
entries = []
@@ -679,7 +683,9 @@ def _build_pages_sx(service: str) -> str:
)
entries.append(entry)
return "\n".join(entries)
result = "\n".join(entries)
_log.debug("_build_pages_sx(%s): built %d entries, %d bytes", service, len(entries), len(result))
return result
def _sx_literal(v: object) -> str:
@@ -752,8 +758,13 @@ def sx_page(ctx: dict, page_sx: str, *,
styles_json = _build_style_dict_json()
# Page registry for client-side routing
import logging
_plog = logging.getLogger("sx.pages")
from quart import current_app
pages_sx = _build_pages_sx(current_app.name)
_plog.debug("sx_page: pages_sx %d bytes for service %s", len(pages_sx), current_app.name)
if pages_sx:
_plog.debug("sx_page: pages_sx first 200 chars: %s", pages_sx[:200])
return _SX_PAGE_TEMPLATE.format(
title=_html_escape(title),