AgentSkillsCN

system-logger

为复杂系统提供智能化、精炼且高效的日志记录高级指南。适用于以下场景:(1) 为新功能添加日志记录;(2) 重构现有日志,以提升可观测性;(3) 调试当前日志尚不足以解决问题的故障;(4) 确保日志遵循架构级最佳实践,从而降低噪声、增强可追溯性。

SKILL.md
--- frontmatter
name: system-logger
description: Advanced guidelines for implementing intelligent, concise, and highly effective logging in complex systems. Use when (1) implementing logging for new features, (2) refactoring existing logs for better observability, (3) debugging issues where current logs are insufficient, or (4) ensuring logs follow architect-level best practices for noise reduction and trace-ability.

System Logger Skill

This skill transforms you into a Senior Log Architect. It provides the framework for writing logs that are minimal, intelligent, and highly effective for debugging complex trading systems.

Core Mandate

Logs must be informative, not noisy. Every log line must justify its existence.

Workflow for Logging

  1. Identify the Event: Is this a business-critical event (INFO), a debugging aid (DEBUG), or a failure (ERROR/WARN)?
  2. Gather Context: What IDs (deployment_id, account_id, job_id) and parameters (symbol, price, quantity) define this event?
  3. Choose the Level:
    • INFO: Significant process milestones.
    • DEBUG: Granular state changes or high-frequency data.
    • WARNING: Unusual but manageable events.
    • ERROR: Failure of a specific task.
  4. Draft the Message: Focus on the "Why" and "What Happened".
  5. Use Formatted Strings: Use logger.info("Message %s", var) instead of f-strings.

Detailed Guidelines

  • Best Practices: Focus on intelligence and noise reduction. See best_practices.md.
  • Codebase Examples: Real-world examples from this project. See examples.md.

Quick Checklist for a "Good Log"

  • Does it include unique identifiers (IDs)?
  • Is the log level appropriate (Info vs Debug)?
  • Is it understandable by someone who didn't write the code?
  • Does it avoid revealing sensitive information (API keys, secrets)?
  • If it's an error, does it capture the exception and stack trace?