Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/dembonauta/skill-doc-generator/structlog-structured-loggingnpx skills add DemboNauta/skill-doc-generator --skill structlog-structured-logginggit clone --depth 1 https://github.com/DemboNauta/skill-doc-generatorWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/dembonauta/skill-doc-generator/structlog-structured-logging)<a href="https://agentmods.dev/skills/dembonauta/skill-doc-generator/structlog-structured-logging"><img src="https://agentmods.dev/badge/skills/dembonauta/skill-doc-generator/structlog-structured-logging.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00061 | $0.04120 |
| Opus 5 | $0.00030 | $0.02060 |
| Sonnet 5 | $0.00012 | $0.00824 |
| Haiku 4.5 | $0.00006 | $0.00412 |
Grade A, and why
structlog-structured-logging scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 624 lines — stays where its author put it; the contents beside it link to each section on GitHub.
structlog — Structured Logging for Python
structlog turns log entries into dictionaries processed through a chain of functions, giving you structured output (JSON, logfmt, pretty console) without sacrificing performance. It has been in production since 2013 and supports threads, asyncio, and greenlets.
Why structlog over stdlib logging
stdlib logging |
structlog |
|---|---|
| String messages, hard to parse | Key-value dictionaries, machine-readable |
| Global mutable state | Immutable bound loggers, safe to pass around |
| Complex handler/formatter hierarchy | Simple processor chain of plain callables |
| No built-in context propagation | contextvars integration out of the box |
| Verbose boilerplate per file | One get_logger() call per file |
Installation
pip install structlog
# For pretty dev exceptions (recommended):
pip install structlog rich
# Windows only (for colors):
pip install structlog rich colorama
Core Concepts
Event dict
Every log call builds a dictionary (event_dict). Context bound via bind() is merged with the kwargs of the log call.
Processor chain
A list of callables, each with signature (logger, method_name, event_dict) -> event_dict. They run in order; the last one must return a string/bytes (the renderer).
Bound logger
The object returned by get_logger(). It's immutable — calling bind() returns a new logger. Use contextvars for mutable global context.
Basic Usage
import structlog
log = structlog.get_logger()
# Simple log
log.info("user_login", user_id=42, ip="1.2.3.4")
# → 2024-01-01 12:00:00 [info ] user_login user_id=42 ip=1.2.3.4
# Bind context to a local logger
log = log.bind(request_id="abc-123", user_id=42)
log.info("processing_started")
log.warning("slow_query", duration_ms=1500)
# Both entries include request_id and user_id automatically
# Unbind a key
log = log.unbind("user_id")
# Replace all context
log = log.new(request_id="new-456")
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 624 lines · 61 tokens per session scan A 725f47de3ce9
structlog-structured-logging is a skill published in the GitHub repository DemboNauta/skill-doc-generator (9 stars, last pushed 4mo ago), licensed MIT. It adds 61 tokens to every session and 4,120 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
frontmcp-observability
Use when adding tracing, structured logging, metrics, or monitoring to a FrontMCP server. Covers zero-config OpenTelemetry distributed tracing across all flows; the this.telemetry API for custom spans, events, and attributes in tools, plugins, agents, and skills; structured JSON logging with trace correlation and…
golang-observability-opentelemetry
Instrumenting Go applications with OpenTelemetry for distributed tracing, Prometheus for metrics, and structured logging with slog.
Observability Checklist
Reviews a service or codebase against a full observability checklist — logs, metrics, traces, and alerting gaps.
logger-design
Design e implementação de logging estruturado com distributed tracing. Enforça schema rígido, correlation IDs, sanitização de PII e boas práticas de observabilidade. Multi-stack (Node.js, Python, Go, Frontend). Triggers on: log, logging, logger, trace, tracing, observability, correlation, span, structured log.
observability
Structured logging (structlog/Python, pino/Node), health endpoints, PM2 and Docker metrics, alerting patterns.
otel-python-style
Python OpenTelemetry style: module-scope tracers/meters, decorators for bounded work, error spans, logs, and no wrappers.