pino

Use Pino for logging in Node.js. Suitable when you need to add structured logs, improve logging performance, configure log levels, format logs for production, or replace console.log with a more appropriate logging solution.

Last repository push
GitHub Stars
219
Forks
38
Issues / PRs
7

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "pino" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-10603cc13cddb37ddad504c51ae2331981d9ef5a3215130050118a1bd1eea685. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Use Pino for logging in Node.js. Suitable when you need to add structured logs, improve logging performance, configure log levels, format logs for production, or replace console.log with a more appropriate logging solution.

0 Downloads

Introduction source: third_party · TerminalSkills · 1.0.0 Reference

SkillPi interpretation

Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: pino
description: >-
  Log in Node.js with Pino. Use when a user asks to add structured logging,
  improve logging performance, configure log levels, format logs for
  production, or replace console.log with proper logging.
license: Apache-2.0
compatibility: 'Node.js 16+, Express, Fastify, Next.js'
metadata:
  author: terminal-skills
  version: 1.0.0
  category: devops
  tags:
    - pino
    - logging
    - nodejs
    - structured
    - observability

Pino

Overview

Pino is the fastest Node.js logger — 5x faster than Winston. It outputs structured JSON logs by default, making them parseable by log aggregators (Datadog, Loki, ELK). Async logging ensures logging never blocks the event loop.

Instructions

Step 1: Basic Setup

// lib/logger.ts — Pino configuration
import pino from 'pino'

export const logger = pino({
  level: process.env.LOG_LEVEL || 'info',
  transport: process.env.NODE_ENV === 'development'
    ? { target: 'pino-pretty', options: { colorize: true } }    // pretty-print in dev
    : undefined,                                                   // JSON in production
  formatters: {
    level: (label) => ({ level: label }),                         // "level": "info" not "level": 30
  },
  base: {
    service: 'api',
    version: process.env.npm_package_version,
  },
})

// Usage
logger.info('Server started')
logger.info({ port: 3000, env: 'production' }, 'Server listening')
logger.error({ err, userId: '123' }, 'Payment processing failed')
logger.warn({ latencyMs: 2500, endpoint: '/api/reports' }, 'Slow request detected')

Step 2: Express Integration

// server.ts — Request logging middleware
import express from 'express'
import pinoHttp from 'pino-http'
import { logger } from './lib/logger'

const app = express()

app.use(pinoHttp({
  logger,
  autoLogging: true,
  customLogLevel: (req, res, err) => {
    if (res.statusCode >= 500 || err) return 'error'
    if (res.statusCode >= 400) return 'warn'
    return 'info'
  },
  customSuccessMessage: (req, res) =>
    `${req.method} ${req.url} ${res.statusCode}`,
  serializers: {
    req: (req) => ({
      method: req.method,
      url: req.url,
      query: req.query,
      userAgent: req.headers['user-agent'],
    }),
    res: (res) => ({
      statusCode: res.statusCode,
    }),
  },
}))

Step 3: Child Loggers

// Add context that persists across a request lifecycle
function createRequestLogger(req) {
  return logger.child({
    requestId: req.headers['x-request-id'] || crypto.randomUUID(),
    userId: req.user?.id,
    ip: req.ip,
  })
}

// Every log from this logger includes requestId, userId, ip
const reqLogger = createRequestLogger(req)
reqLogger.info('Processing order')
reqLogger.info({ orderId: 'ord_123', amount: 99.99 }, 'Order created')
// Output: {"level":"info","requestId":"abc-123","userId":"user-456","orderId":"ord_123","amount":99.99,"msg":"Order created"}

Guidelines

  • Always use structured JSON logging in production — not string interpolation.
  • Context first, message second: logger.info({ orderId }, 'Order created') not logger.info('Order created for ' + orderId).
  • Use child loggers to add request context (requestId, userId) that propagates to all logs.
  • Pino's async mode (pino({ transport })) prevents logging from blocking the event loop.
  • Use pino-pretty only in development — JSON logs are for machines, not humans.

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 提供 Node.js 结构化日志记录的完整解决方案
  • 覆盖从基础配置到生产环境集成的典型使用场景
Trigger Precision90/100

Highlights

  • 触发场景描述清晰完整,边界明确
Structure and Standards95/100

Highlights

  • 文档结构清晰,分步骤递进说明
  • 包含完整可运行的代码示例和最佳实践指南
Execution Reliability90/100

Highlights

  • 工具来源和参数配置正确
  • 覆盖开发和生产环境的差异化配置
Evidence Verifiability (mean of the first four)88/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.