Command Palette

Search for a command to run...

Назад к скиллам
скилл № 14423

logging

Use when writing or reviewing ANY service/backend/frontend code that runs a request path, calls an external system, or makes a decision that could fail in…

БесплатноБез исполняемых скриптов
FuzeOneот FuzeOne★ 18 звёзд на GitHub

Установить logging в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

logging / observability-logging

Structured, leveled, correlated logging on every critical path. Silent code is undebuggable in prod — this skill is the family standard for making sure it never ships that way.

Why this is a hard rule (the incident that wrote it)

A production login hung, and it cost hours to diagnose because FuzeFront's security service had no structured logging — 210 raw console.* calls and the auth-critical files (the OIDC authorize/callback hairpin) were completely silent. There was nothing to grep, no timing, no correlation. Once per-step timing logs were added at the boundaries, the root cause — a 6.5s authorize hairpin — was found in 30 seconds.

The lesson, encoded here as policy: leveled + structured + correlated logging on critical paths is not optional. A path with no logs is a path you cannot debug in prod; when it breaks (and auth/payment paths break at the worst time), you are blind. Instrument first, especially at boundaries and decision branches.

1. Structured JSON via pino — one shared logger per service

  • Family standard: pino for Node/TypeScript services. Structured JSON to stdout — the platform's log stack (Loki) ingests JSON; free-text console.log is not queryable.
  • One shared logger util per service (src/lib/logger.ts or equivalent). Never new a logger ad hoc per file, and never console.* in service code. Everything derives from the one root logger (child loggers, below).
  • Never console.log/console.error in new service code. console.* is unleveled (can't be filtered), unstructured (can't be queried), and unredacted (leaks secrets). The gate for new code is zero raw console.*.

2. Levels + LOG_LEVEL — flip verbosity WITHOUT a redeploy

Verbosity is controlled by the LOG_LEVEL env var, read at startup. Prod default: info. To debug a live incident you set LOG_LEVEL=debug and restart the pod (or use a runtime level endpoint) — no code change, no rebuild, no redeploy. This is the whole point: the debug detail is already written into the code, dormant at info, and you turn it on when you need it.

Level Semantics Examples
ERROR An operation failed; needs attention. Always logged with context (see §3). unhandled exception, external call failed after retries, invariant violated, auth misconfig
WARN Degraded / recoverable / suspicious, but handled. retry succeeded on 2nd attempt, fell back to cache, deprecated path hit, slow dependency over threshold
INFO Flow milestones — the request-level story a human follows. Prod-safe volume. request received, auth succeeded for user X, order created, external call initiated (summary), request completed
DEBUG Per-hop detail — every boundary crossing incl. elapsed ms, decision-branch inputs/outcomes, intermediate state. Off in prod by default. authorize() start, authorize() end elapsed=6512ms, "chose branch B because hasPassword=null", DB query issued/returned rows=N

Rule of thumb: INFO tells the story, DEBUG tells the timing and the why. If you'd want it during a 2am incident but not in steady-state prod noise, it's DEBUG.

3. Boundary logging — the rule that finds the 6.5s hairpin

Every external call logs start + end + elapsed ms. External = any hop out of the process: HTTP/fetch to another service or provider (Authentik, Permit, Stripe, Unleash), a DB query, a cache/Redis op, a Kafka produce/consume, a filesystem/network call. This is what turned "the login hangs somewhere" into "authorize() took 6512ms" in 30s.

DEBUG  authentik.authorize start   { reqId, op: "authorize" }
DEBUG  authentik.authorize end     { reqId, op: "authorize", elapsedMs: 6512, status: 200 }
  • Every caught error logs WITH context — never catch {} (a swallowed error is a silent failure) and never catch(e){ throw e } with nothing logged. Log the error object, the operation, and the identifying context (reqId, userId/orgId, the resource id, the upstream status). An error with no context is nearly as useless as no error.
  • Critical-path decision branches are observable. Where the code chooses a path on auth/payment/data flows, log the input that drove it and which branch was taken — including the fail-closed cases (reveal-once token already revealed; remove-last-2FA-factor → 409; demote-the-last-admin; hasPassword: null → "set a password first"). If prod took the wrong branch, the log must let you see why.

4. Correlation IDs — one request, one greppable thread

Every request gets a reqId (accept an inbound x-request-id / traceparent if present, else generate a UUID) bound as a child-logger field at the entry middleware, and that child logger is used for the rest of the request:

const reqId = req.headers['x-request-id'] ?? randomUUID();
req.log = logger.child({ reqId
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл logging?

Use when writing or reviewing ANY service/backend/frontend code that runs a request path, calls an external system, or makes a decision that could fail in prod — the family structured-logging standard. Covers pino JSON logging, the ERROR/WARN/INFO/DEBUG level semantics + env-flippable LOG_LEVEL, boundary logging (every external call logs start/end/elapsed ms), per-request correlation IDs (reqId child logger), distributed-trace correlation (trace_id/span_id via @izzywdev/fuzefront-telemetry, OTel traces to FuzeInfra's Collector), MANDATORY secret redaction, critical-path-first incremental migration off raw console.*, and the implementer + reviewer definition-of-done. Owned by backend-engineer/frontend-engineer (implement) + the reviewer (enforce).

Как установить скилл logging?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл logging запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить logging с