Back to list
dasien

logging-strategies

by dasien

Multi-agent development system template for Claude Code with specialized agents, task queue management, and automated workflows

3🍴 1📅 Jan 24, 2026

SKILL.md


name: "Logging Strategies" description: "Implement structured logging with appropriate levels, context, and correlation for effective debugging and monitoring" category: "observability" required_tools: ["Read", "Write", "Edit"]

Purpose

Create comprehensive logging that enables debugging, monitoring, and analysis of application behavior in production.

When to Use

  • Implementing new features
  • Debugging production issues
  • Performance monitoring
  • Security auditing

Key Capabilities

  1. Structured Logging - JSON logs with context
  2. Log Levels - Appropriate severity classification
  3. Correlation - Trace requests across services

Example

import logging
import json
from datetime import datetime
import uuid

class StructuredLogger:
    def __init__(self, service_name):
        self.service = service_name
        self.logger = logging.getLogger(service_name)
    
    def log(self, level, message, **context):
        log_entry = {
            'timestamp': datetime.utcnow().isoformat(),
            'service': self.service,
            'level': level,
            'message': message,
            **context
        }
        
        log_line = json.dumps(log_entry)
        
        if level == 'ERROR':
            self.logger.error(log_line)
        elif level == 'WARNING':
            self.logger.warning(log_line)
        elif level == 'INFO':
            self.logger.info(log_line)
        else:
            self.logger.debug(log_line)
    
    def with_context(self, **context):
        class ContextLogger:
            def __init__(self, parent, ctx):
                self.parent = parent
                self.context = ctx
            
            def info(self, message, **extra):
                self.parent.log('INFO', message, **{**self.context, **extra})
            
            def error(self, message, **extra):
                self.parent.log('ERROR', message, **{**self.context, **extra})
        
        return ContextLogger(self, context)

# Usage
logger = StructuredLogger('api-service')

def handle_request(request_id, user_id):
    request_logger = logger.with_context(
        request_id=request_id,
        user_id=user_id
    )
    
    request_logger.info("Processing request")
    
    try:
        # Business logic
        result = process_order()
        request_logger.info("Order processed", order_id=result.id)
    except Exception as e:
        request_logger.error("Order failed", error=str(e), exc_info=True)

Best Practices

  • ✅ Use structured logging (JSON)
  • ✅ Include correlation IDs
  • ✅ Log at appropriate levels
  • ✅ Include context (user_id, request_id)
  • ✅ Log errors with stack traces
  • ❌ Avoid: Logging sensitive data (passwords, tokens)
  • ❌ Avoid: Excessive debug logging in production

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon