Implement structured logging with proper log levels and sensitive data handling. Use when: adding logging, debugging, setting up observability. Keywords: logging, log level, structured logging, observability, 日誌, 記錄, 結構化日誌.
/plugin marketplace add AsiaOstrich/universal-dev-standards/plugin install asiaostrich-universal-dev-standards@AsiaOstrich/universal-dev-standardsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Language: English | 繁體中文
Version: 1.0.0 Last Updated: 2025-12-30 Applicability: Claude Code Skills
This skill helps implement consistent, structured, and actionable application logs across all environments.
| Level | Code | When to Use | Production |
|---|---|---|---|
| TRACE | 10 | Very detailed debugging info | Off |
| DEBUG | 20 | Detailed debugging info | Off |
| INFO | 30 | Normal operation events | On |
| WARN | 40 | Potential issues, recoverable | On |
| ERROR | 50 | Errors that need attention | On |
| FATAL | 60 | Critical failures | On |
Is it debugging only? → DEBUG (off in prod)
Normal operation completed? → INFO
Something unexpected but OK? → WARN
Operation failed? → ERROR
App cannot continue? → FATAL
| Level | Examples |
|---|---|
| TRACE | Function entry/exit, loop iterations, variable values |
| DEBUG | State changes, configuration values, query parameters |
| INFO | App startup/shutdown, user actions, scheduled tasks |
| WARN | Deprecated API, retry attempts, resource approaching limits |
| ERROR | Failed operations, caught exceptions, integration failures |
| FATAL | Unrecoverable errors, startup failures, lost critical resources |
{
"timestamp": "2025-01-15T10:30:00.123Z",
"level": "INFO",
"message": "User login successful",
"service": "auth-service",
"environment": "production"
}
{
"timestamp": "2025-01-15T10:30:00.123Z",
"level": "INFO",
"message": "User login successful",
"service": "auth-service",
"environment": "production",
"trace_id": "abc123",
"span_id": "def456",
"user_id": "usr_12345",
"request_id": "req_67890",
"duration_ms": 150,
"http_method": "POST",
"http_path": "/api/v1/login",
"http_status": 200
}
Use snake_case and prefix with domain:
| Domain | Common Fields |
|---|---|
| HTTP | http_method, http_path, http_status, http_duration_ms |
| Database | db_query_type, db_table, db_duration_ms, db_rows_affected |
| Queue | queue_name, queue_message_id, queue_delay_ms |
| User | user_id, user_role, user_action |
| Request | request_id, trace_id, span_id |
For complete standards, see:
For AI assistants, use the YAML format files for reduced token usage:
ai/standards/logging.ai.yaml// Bad
logger.info('Login attempt', { password: userPassword });
// Good
logger.info('Login attempt', { password: '***REDACTED***' });
// Good - mask partial
logger.info('Card processed', { last_four: '4242' });
{
"level": "ERROR",
"message": "Database connection failed",
"error_type": "ConnectionError",
"error_message": "Connection refused",
"error_code": "ECONNREFUSED",
"stack": "Error: Connection refused\n at connect (/app/db.js:45:11)..."
}
Always include:
logger.error('Failed to process order', {
error_type: err.name,
error_message: err.message,
order_id: orderId,
user_id: userId,
retry_count: 2,
stack: err.stack
});
{"timestamp":"2025-01-15T10:30:00.123Z","level":"INFO","message":"Request completed","request_id":"req_123","duration_ms":45}
2025-01-15T10:30:00.123Z [INFO] Request completed request_id=req_123 duration_ms=45
| Environment | Level | Strategy |
|---|---|---|
| Development | DEBUG | All logs |
| Staging | INFO | Most logs |
| Production | INFO | Sampling for high-volume |
This skill supports project-specific configuration.
CONTRIBUTING.md for logging guidelinesIf no logging standard found:
CONTRIBUTING.md:## Logging Standards
### Log Levels
- DEBUG: Development only, detailed diagnostic info
- INFO: Normal operations (startup, user actions, tasks)
- WARN: Unexpected but recoverable situations
- ERROR: Failures that need investigation
### Required Fields
All logs must include: timestamp, level, message, service, request_id
### Sensitive Data
Never log: passwords, tokens, credit cards, SSN
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2025-12-30 | Initial release |
This skill is released under CC BY 4.0.
Source: universal-dev-standards
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.