用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/AsiaOstrich/universal-dev-standards --skill logging命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
[UDS] 以 Claude 原生 Agent tool 编排多任务执行计划(DAG-based,无外部引擎)。 Use when: executing a plan.json file with parallel/sequential task dependencies. Keywords: orchestrate, plan, execute, DAG, task plan, 编排, 执行计划, 并行.
[UDS] 从 Spec 文档、OpenSpec 变更或自由文本需求生成 plan.json。 Use when: converting specifications into executable task plans for /orchestrate. Keywords: plan, spec, task plan, 计划, 规格, 任务, plan.json, DAG.
[UDS] AI 辅助 git push 安全层:质量门禁 + 协作护栏。 Use when: pushing commits, force pushing, pushing to protected branches, pushing feature branches. Keywords: git push, force push, protected branch, quality gate, push receipt, PR automation, 推送, 保护分支, 质量门禁.
正在显示 SKILL.md
基于 SOC 职业分类
| name | logging |
| description | [UDS] 實作結構化日誌,包含正確的日誌層級和敏感資料處理 |
| source | ../../../../skills/logging-guide/SKILL.md |
| source_version | 1.0.0 |
| translation_version | 1.0.0 |
| last_synced | "2026-01-08T00:00:00.000Z" |
| status | current |
| scope | universal |
語言: English | 繁體中文
版本: 1.0.0 最後更新: 2025-12-30 適用範圍: Claude Code Skills
此技能幫助在所有環境中實作一致、結構化且可操作的應用程式日誌。
| 層級 | 代碼 | 使用時機 | 生產環境 |
|---|---|---|---|
| TRACE | 10 | 非常詳細的除錯資訊 | 關閉 |
| DEBUG | 20 | 詳細的除錯資訊 | 關閉 |
| INFO | 30 | 正常操作事件 | 開啟 |
| WARN | 40 | 潛在問題,可恢復 | 開啟 |
| ERROR | 50 | 需要注意的錯誤 | 開啟 |
| FATAL | 60 | 嚴重故障 | 開啟 |
只用於除錯? → DEBUG(生產環境關閉)
正常操作完成? → INFO
意外但沒問題的情況? → WARN
操作失敗? → ERROR
應用程式無法繼續? → FATAL
| 層級 | 範例 |
|---|---|
| TRACE | 函式進入/離開、迴圈迭代、變數值 |
| DEBUG | 狀態變更、設定值、查詢參數 |
| INFO | 應用啟動/關閉、使用者操作、排程任務 |
| WARN | 已棄用 API、重試嘗試、資源接近上限 |
| ERROR | 失敗的操作、捕獲的例外、整合失敗 |
| FATAL | 無法恢復的錯誤、啟動失敗、失去關鍵資源 |
{
"timestamp": "2025-01-15T10:30:00.123Z",
"level": "INFO",
"message": "使用者登入成功",
"service": "auth-service",
"environment": "production"
}
{
"timestamp": "2025-01-15T10:30:00.123Z",
"level": "INFO",
"message": "使用者登入成功",
"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
}
使用 snake_case 並加上領域前綴:
| 領域 | 常用欄位 |
|---|---|
| HTTP | http_method, http_path, http_status, http_duration_ms |
| 資料庫 | db_query_type, db_table, db_duration_ms, db_rows_affected |
| 佇列 | queue_name, queue_message_id, queue_delay_ms |
| 使用者 | user_id, user_role, user_action |
| 請求 | request_id, trace_id, span_id |
完整標準請參考:
AI 助手可使用 YAML 格式檔案以減少 Token 使用量:
ai/standards/logging.ai.yaml// 不好
logger.info('登入嘗試', { password: userPassword });
// 好
logger.info('登入嘗試', { password: '***已編修***' });
// 好 - 部分遮罩
logger.info('卡片已處理', { last_four: '4242' });
{
"level": "ERROR",
"message": "資料庫連線失敗",
"error_type": "ConnectionError",
"error_message": "連線被拒絕",
"error_code": "ECONNREFUSED",
"stack": "Error: Connection refused\n at connect (/app/db.js:45:11)..."
}
務必包含:
logger.error('處理訂單失敗', {
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_id":"req_123","duration_ms":45}
2025-01-15T10:30:00.123Z [INFO] 請求完成 request_id=req_123 duration_ms=45
| 環境 | 層級 | 策略 |
|---|---|---|
| 開發 | DEBUG | 所有日誌 |
| 測試 | INFO | 大部分日誌 |
| 生產 | INFO | 高流量端點採樣 |
此技能支援專案特定設定。
CONTRIBUTING.md 中的日誌指南若未找到日誌標準:
CONTRIBUTING.md 中記錄:## 日誌標準
### 日誌層級
- DEBUG: 僅開發環境,詳細診斷資訊
- INFO: 正常操作(啟動、使用者操作、任務)
- WARN: 意外但可恢復的情況
- ERROR: 需要調查的失敗
### 必要欄位
所有日誌必須包含:timestamp, level, message, service, request_id
### 敏感資料
絕不記錄:密碼、Token、信用卡、身分證字號
| 版本 | 日期 | 變更 |
|---|---|---|
| 1.0.0 | 2025-12-30 | 初始發布 |
此技能採用 CC BY 4.0 授權。