Token导航 LogoToken导航TokenDH.com
开发规范需要联网github未标认证来源可访问许可证需确认审计通过

logging-best-practices记录最佳实践

Agent Skill

logging-best-practices 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

272

周安装

11

GitHub Stars

9

下载量

85
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:logging-best-practices(记录最佳实践)
来源仓库:https://github.com/nbbaier/agent-skills
仓库路径:skills/logging-best-practices
安装命令:
npx skills add https://github.com/nbbaier/agent-skills --skill logging-best-practices
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/nbbaier/agent-skills --skill logging-best-practices

简介

logging-best-practices 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装,需确认权限和维护状态。
  • 使用前建议核实是否会触发联网、命令执行或文件读写操作。
  • 可结合原始 README 进一步核验具体用法和功能边界。

SKILL.md

This skill is adpated from "Logging sucks. And here's how to make it better. by Boris Tane.

When helping with logging, observability, or debugging strategies, follow these principles:

Core Philosophy

  • Logs are optimized for querying, not writing — always design with debugging in mind
  • Context is everything — a log without correlation IDs is useless in distributed systems
  • Logs are for humans during incidents, not just for compliance or "just in case"
  • If you can't filter and search your logs effectively, they provide zero value

Structured Logging Requirements

  • Always use key-value pairs (JSON) instead of string interpolation
  • Bad: "Payment failed for user 123"
  • Good: {"event": "payment_failed", "user_id": "123", "reason": "insufficient_funds", "amount": 99.99}
  • Structured logs are machine-parseable, enabling aggregation, alerting, and dashboards

Required Fields for Every Log Event

  • timestamp — ISO 8601 with timezone (e.g., 2025-01-24T20:00:00Z)
  • level — debug, info, warn, error (be consistent, don't invent new levels)
  • event — machine-readable event name, snake_case (e.g., user_login_success)
  • request_id or trace_id — for correlating logs across a single request
  • service — which service/application emitted this log
  • environment — prod, staging, dev

Examples of High-Cardinality Fields (always include when available):

  • user_id, org_id, account_id — who is affected
  • request_id, trace_id, span_id — for distributed tracing
  • order_id, transaction_id, job_id — domain-specific identifiers

These fields are what make logs actually queryable during incidents. Without them, you're grepping through millions of lines blindly.

Look for opportunities for high-cardinality fields that can help you identify the root cause of an issue quickly.

Context Propagation

  • Pass trace/request IDs through all service boundaries (HTTP headers, message queues, etc.)
  • Downstream services must inherit correlation IDs from upstream
  • Use middleware or interceptors to automatically inject context into every log
  • For async jobs, store and restore the original request context

Log Levels — Use Them Correctly:

  • debug — Verbose details for local development, usually disabled in production
  • info — Normal operations worth recording (user actions, job completions, deploys)
  • warn — Something unexpected happened but the system handled it (retries, fallbacks)
  • error — Something failed and likely needs human attention (exceptions, failed requests)

Don't log errors for expected conditions (e.g., user enters wrong password)

What to Log:

  • Request entry and exit points (with duration)
  • State transitions (order created → paid → shipped)
  • External service calls (with latency and response codes)
  • Authentication and authorization events
  • Background job starts, completions, and failures
  • Retry attempts and circuit breaker state changes

What NOT to Log:

  • Sensitive data (passwords, tokens, PII, credit card numbers)
  • Logs inside tight loops (will generate millions of useless entries)
  • Success cases that provide no debugging value
  • Redundant information already captured by infrastructure (load balancer logs, etc.)

Naming Conventions:

  • Be consistent across all services — agree on field names as a team
  • Use snake_case for field names: user_id, not userId or user-id
  • Use past-tense verbs for events: payment_completed, not complete_payment
  • Prefix events by domain when helpful: auth.login_failed, billing.invoice_created

Performance Considerations:

  • Use sampling for high-volume debug logs in production
  • Avoid logging inside hot paths unless absolutely necessary
  • Buffer and batch log writes to reduce I/O overhead
  • Consider log levels that can be changed at runtime without redeploying

During Incidents:

  • Your logs should answer: Who was affected? What failed? When? Why?
  • If you can't answer these within 5 minutes of querying, your logging strategy needs work
  • Post-incident: add the logs you wished you had

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

31.92%
按下载量换算27

Claude

31.78%
按下载量换算27

Cursor

20.67%
按下载量换算18

Gemini CLI

9.66%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills