AgentSkillsCN

mythosmud-logging-standards

使用MythosMUD的日志记录机制:从server.logging.enhanced_logging_config中获取get_logger,采用结构化key=value参数形式,避免使用f-string或context=参数。适用于新增或编辑Python日志配置,或当用户提及日志或日志记录时使用。

SKILL.md
--- frontmatter
name: mythosmud-logging-standards
description: Use MythosMUD logging: get_logger from server.logging.enhanced_logging_config, structured key=value args, no f-strings or context= parameter. Use when adding or editing Python logging, or when the user mentions logs or logging.

MythosMUD Logging Standards

Import

Always use the project logger:

python
from server.logging.enhanced_logging_config import get_logger
logger = get_logger(__name__)

Never use import logging or logging.getLogger().

Structured Logging

Pass data as keyword arguments (key=value). Do not use f-strings or the deprecated context= parameter.

Correct:

python
logger.info("User action completed", user_id=user.id, action="login", success=True)
logger.error("Request failed", path=request.url.path, status_code=500)

Wrong:

python
logger.info(f"User {user_id} performed {action}")  # No f-strings
logger.info("message", context={"key": "value"})  # No context= parameter

Optional Helpers

  • Request context: bind_request_context(correlation_id=id, user_id=uid) when handling requests.
  • Performance: with measure_performance("operation"): for timing blocks.

Import these from server.logging.enhanced_logging_config when needed.

Summary

DoDo not
get_logger(__name__)logging.getLogger()
logger.info("msg", key=value)logger.info(f"msg {x}")
Key-value argscontext={"key": "value"}

Reference

  • Full rules: CLAUDE.md "LOGGING STANDARDS" and "Example Patterns"