ワンクリックで
logging-strategies
Implement structured logging with appropriate levels, context, and correlation for effective debugging and monitoring
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Implement structured logging with appropriate levels, context, and correlation for effective debugging and monitoring
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Design AI agents with appropriate capabilities, tools, and personas for specific software development tasks
Design RESTful APIs with proper resource modeling, HTTP methods, error handling, and clear contracts following REST principles
Document APIs comprehensively with signatures, parameters, return values, errors, and working code examples for developer reference
Implement robust third-party API integrations with proper authentication, error handling, and rate limiting
Apply proven architectural patterns (MVC, layered, microservices) to create maintainable systems with clear separation of concerns
Systematically reproduce, diagnose, and analyze bugs to determine root cause, assess severity, and plan fix strategy
| 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"] |
Create comprehensive logging that enables debugging, monitoring, and analysis of application behavior in production.
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)