:::warning AUTO-GENERATED — do not edit
This page is generated from the MCP server snapshot content/backend-mcp.json.
Edit the source MCP server (not this file), then run npm run generate.
:::
Initialize python_logger.setup_logger and emit structured logs to Kibana
When to use: A route or module needs observability — structured logs that flow to Kibana.
Prerequisites
- The module/route you want to instrument exists.
Steps
Step 1: Fetch the canonical structured logging pattern.
Tools: get_logging_pattern
Step 2: Initialize the logger once via python_logger.setup_logger(...).
Step 3: Emit structured logs (key/value fields, not interpolated strings) at request entry, key branches, and errors.
Step 4: Run the verify gate.
Tools: validate_backend_endpoint
Full recipe definition
The complete machine-readable recipe as returned by the MCP server:
{
"id": "wire-logging",
"title": "Initialize python_logger.setup_logger and emit structured logs to Kibana",
"when": "A route or module needs observability — structured logs that flow to Kibana.",
"prerequisites": [
"The module/route you want to instrument exists."
],
"steps": [
{
"action": "Fetch the canonical structured logging pattern.",
"tools": [
"get_logging_pattern"
],
"note": "Returns the exact setup_logger call and how to emit structured fields. Do not use bare print() or the root logging module."
},
{
"action": "Initialize the logger once via python_logger.setup_logger(...).",
"files": [
"src/routes/<domain>_routes.py"
],
"note": "Call setup_logger at module import with the module/service name — do not re-initialize per request."
},
{
"action": "Emit structured logs (key/value fields, not interpolated strings) at request entry, key branches, and errors.",
"files": [
"src/routes/<domain>_routes.py"
],
"note": "Structured fields are what Kibana indexes. Never log secrets, tokens, or full JWTs."
},
{
"action": "Run the verify gate.",
"tools": [
"validate_backend_endpoint"
],
"note": "Follow run-verify."
}
],
"filesToCreate": [],
"validation": [
"Logger is created via python_logger.setup_logger.",
"Logs carry structured fields (visible/queryable in Kibana).",
"No secrets or tokens appear in log output."
],
"doneCriteria": [
"Module logs via the setup_logger logger with structured fields.",
"run-verify passes."
],
"commonMistakes": [
"Using print() or the root logging module instead of setup_logger.",
"Re-initializing the logger on every request.",
"Logging tokens/secrets or PII.",
"Emitting only free-text messages with no structured fields for Kibana."
],
"relatedRecipes": [
"create-endpoint",
"run-verify"
]
}