structlog-logging-specialist

Configure Structlog for JSON logging with async-safe correlation context in HuleEdu services.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/paunchygent/docforge --skill structlog-logging-specialist
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: structlog-logging-specialist
Source: https://github.com/paunchygent/docforge/tree/main/frontend/.claude/skills/structlog-logging
Command: npx skills add https://github.com/paunchygent/docforge --skill structlog-logging-specialist

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides you to implement structured logging with Structlog in HuleEdu services, enabling cross-service correlation, async-safe context propagation, and production-grade JSON output.

Core Features & Use Cases

  • Structlog Configuration: Production (JSON) vs Development (colored console) setup
  • Correlation Propagation: HTTP request → logs, Kafka events → logs, cross-service tracing
  • Context Variables: Async-safe context binding with bind_contextvars
  • Logger Creation: Service-specific logger instances
  • Event Logging & Error Integration: Structured logging with correlation context in error handlers
  • JSON Output: Production-ready JSON logs for Loki

Quick Start

Install and configure the logging utilities, create module loggers with create_service_logger, bind correlation context at request boundaries, emit logs with structured fields such as correlation_id and event_id, and ensure to clear contextvars at the end of processing.

Frequently Asked Questions about structlog-logging-specialist

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement structured logging with correlation IDs across microservices?

Structured logging with correlation propagation binds async-safe context variables at request boundaries, automatically including correlation_id in all downstream logs. Use contextvars binding to attach trace data that flows across HTTP requests and Kafka events, enabling cross-service tracing without manual parameter passing.

What's the difference between production JSON logs and development console output?

Structlog supports environment-specific rendering: production outputs JSON for log aggregation systems like Loki, while development uses colored console output for readability. Configuration switches between these modes based on environment, maintaining identical logging calls in code.

How do I bind and clear context variables safely in async code?

Async-safe context binding with bind_contextvars attaches correlation data to the current execution context, automatically isolating it per async task. Clear contextvars at request or event boundaries to prevent context leaks between concurrent operations.

Can I use structured logging for Kafka event processing?

Yes, Structlog integrates correlation propagation into Kafka event handlers, automatically including correlation_id and event_id in logs. Context variables bind at event consumption and clear after processing, maintaining trace continuity across async message streams.

Do I need to modify error handling to include correlation context in logs?

Error handlers automatically include bound context variables in structured logs without modification. Correlation data flows into exception logs through the same contextvars mechanism, enabling correlated error tracing across services.

How do I create service-specific logger instances?

Create module-specific loggers using create_service_logger with service name and environment configuration. Each logger instance inherits correlation context from contextvars and outputs logs in the configured format (JSON or console).