mcpField
P
pino-logging

pino-logging

github.com/oakossDevelopment20196 installsUpdated 10w ago
Repository

About pino-logging

A skill for using Pino, a high-performance JSON logger for Node.js. It guides developers through structured, request-scoped logging, redaction, and transport configuration.

Key features

  1. 01Structured NDJSON logging
  2. 02Request-scoped child loggers
  3. 03Sensitive-field redaction
  4. 04Worker-thread transports
  5. 05HTTP and framework logging

Use cases

  1. 01Add structured logs to a Node.js service
  2. 02Attach correlation IDs to request logs
  3. 03Redact passwords or tokens
  4. 04Route logs to multiple destinations

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/oakoss/agent-skills --skill pino-logging

After installing, type/pino-loggingin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
child-loggers-and-redaction.md
http-and-frameworks.md
setup-and-configuration.md
transports.md

Details

From the project README

Pino Logging

High-performance JSON logger for Node.js. Transports run in worker threads to keep the main event loop free. Produces NDJSON by default with automatic level, time, pid, hostname, and msg fields.

When to use: Structured logging in Node.js applications, request-scoped logging with correlation IDs, sensitive data redaction, multi-destination log routing, framework logging integration.

When NOT to use: Browser-only logging (pino has limited browser support), simple console.log debugging during development, projects that need human-readable logs by default (pino outputs JSON; use pino-pretty for dev).

Package: pino (v10+)

Quick Reference

PatternAPIKey Points
Basic loggerpino()Defaults: level info, JSON to stdout
Set levelpino({ level: 'debug' })fatal > error > warn > info > debug > trace
Log with contextlogger.info({ userId }, 'msg')First arg is merged object, second is message
Error logginglogger.error({ err }, 'failed')Pass errors as err key for serialization
Child loggerlogger.child({ requestId })Bindings persist on all child logs
Redactionpino({ redact: ['password'] })Paths use dot notation, supports wildcards
Transport (worker)pino({ transport: { target } })Runs in worker thread, non-blocking
Multiple transportstransport: { targets: [...] }Different levels per destination
Pretty print (dev)target: 'pino-pretty'Dev only — not for production
File transporttarget: 'pino/file'Built-in, with mkdir option
Rotating filestarget: 'pino-roll'Size and time-based rotation
HTTP middlewarepinoHttp() from pino-httpAuto request/response logging
Request IDgenReqId option in pino-httpGenerate or forward X-Request-Id
Serializersserializers: { req, res, err }Transform objects before logging
Formattersformatters: { level, log }Rename fields, transform output
Custom levelscustomLevels: { http: 35 }Add levels between built-in ones
Async destinationpino.destination({ sync: false })Buffered async writes
Fastifyfastify({ logger: true })Built-in pino, request.log
Honohono-pino middlewarec.get('logger') in handlers

Common Mistakes

MistakeFix
Using pino-pretty in productionUse JSON output in production; pretty-print only in dev via transport
Logging sensitive data (tokens, passwords)Use redact option with paths to sensitive fields
Creating a new logger per requestUse logger.child({ requestId }) for request-scoped context
Blocking main thread with file writesUse pino.transport() — runs in a worker thread
Using JSON.stringify on errorsPass errors as { err } — pino serializes stack, cause chain
Not forwarding X-Request-Id headerUse genReqId in pino-http to check headers first
Logging inside hot loopsCheck logger.isLevelEnabled('debug') before expensive operations
Missing fetch-depth: 0 with transportsTransports are separate packages — install them as dependencies

Delegation

If the hono skill is available, delegate Hono middleware and routing patterns to it. If the vitest-testing skill is available, delegate test setup and mocking patterns to it. If the sentry-setup-logging skill is available, delegate Sentry integration to it — it covers Sentry.pinoIntegration() for forwarding pino logs to Sentry. Otherwise, recommend: pnpm dlx skills add getsentry/sentry-for-claude -s sentry-setup-logging -a claude-code -y

References

Comments

Markdown supported