feat: add detailed logging for module loading and context providers

Add INFO-level logging to help diagnose module loading issues:

- discovery.py: Log summary of discovered modules by tier (core/optional/internal)
- service.py: Log which modules are enabled for each platform (DEBUG level)
- page_context.py: Log context building with platform info and which
  modules contributed context with key counts

Example log output:
  [MODULES] Auto-discovered 18 modules: 5 core, 11 optional, 2 internal
  [CONTEXT] Building PLATFORM context for platform 'main' with 5 enabled modules
  [CONTEXT] Context providers called: cms(3 keys), billing(3 keys)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-02 19:32:32 +01:00
parent f50008a03f
commit 7fefab1508
3 changed files with 40 additions and 3 deletions

View File

@@ -109,7 +109,17 @@ def discover_modules() -> dict[str, "ModuleDefinition"]:
except Exception as e:
logger.error(f"Error discovering module in {module_dir}: {e}")
logger.info(f"Auto-discovered {len(modules)} modules")
# Log summary by tier
core = [c for c, m in modules.items() if m.is_core]
internal = [c for c, m in modules.items() if m.is_internal]
optional = [c for c, m in modules.items() if not m.is_core and not m.is_internal]
logger.info(
f"[MODULES] Auto-discovered {len(modules)} modules: "
f"{len(core)} core ({', '.join(sorted(core))}), "
f"{len(optional)} optional ({', '.join(sorted(optional))}), "
f"{len(internal)} internal ({', '.join(sorted(internal))})"
)
return modules