{"id":16175,"library":"pino-http-print","title":"Pino HTTP Debug Printer","description":"pino-http-print is a specialized utility for formatting and printing HTTP request and response logs generated by Pino-compatible HTTP loggers (such as pino-http, express-pino-logger, restify-pino-logger, or koa-pino-logger) into a concise, human-readable, `curl`-like output. It functions primarily as a Pino transport, transforming raw JSON log lines into an easily digestible format suitable for console debugging or integration with other output streams. The current stable version is v4.0.0. As part of the pinojs ecosystem, releases typically align with broader Pino updates, ensuring compatibility with current Node.js versions and core Pino features. Its key differentiation lies in its dedicated focus on structuring HTTP log data for rapid analysis, while also capable of leveraging `pino-pretty` to format general application logs when the `all` option is enabled, providing a cohesive debugging experience.","status":"active","version":"4.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/pinojs/pino-http-print","tags":["javascript"],"install":[{"cmd":"npm install pino-http-print","lang":"bash","label":"npm"},{"cmd":"yarn add pino-http-print","lang":"bash","label":"yarn"},{"cmd":"pnpm add pino-http-print","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core logging library that this package extends as a transport, necessary for its primary function.","package":"pino","optional":false},{"reason":"Used internally for formatting non-HTTP log messages when the 'all' option is enabled, and for processing the 'prettyOptions' configuration.","package":"pino-pretty","optional":true}],"imports":[{"note":"When using pino-http-print directly as a module, for instance, to pass a printer stream to `pino-http`, `express-pino-logger`, etc., `httpPrintFactory` is a named export.","wrong":"import pinoHttpPrint from 'pino-http-print'","symbol":"httpPrintFactory","correct":"import { httpPrintFactory } from 'pino-http-print'"},{"note":"For CommonJS environments, `httpPrintFactory` is accessed as a named property of the module export. The module does not provide a default export.","wrong":"const pinoHttpPrint = require('pino-http-print')","symbol":"httpPrintFactory","correct":"const { httpPrintFactory } = require('pino-http-print')"},{"note":"When configured as a Pino transport, the package name is provided as a string value to the `target` property within the transport configuration object.","wrong":"const transport = pino.transport('pino-http-print', { ... })","symbol":"'pino-http-print'","correct":"const transport = pino.transport({ target: 'pino-http-print', options: { ... } })"}],"quickstart":{"code":"const pino = require('pino');\nconst http = require('http');\nconst pinoHttp = require('pino-http');\n\n// Configure pino-http-print as a Pino transport\nconst transport = pino.transport({\n  target: 'pino-http-print',\n  options: {\n    destination: 1, // Output to stdout\n    all: true,      // Also print non-HTTP logs using pino-pretty\n    colorize: true,\n    translateTime: 'SYS:HH:MM:ss', // Custom time format\n    prettyOptions: {\n      ignore: 'pid,hostname', // Example pino-pretty option to ignore fields\n    }\n  }\n});\n\n// Create a Pino logger instance using the configured transport\nconst logger = pino(transport);\n\n// Integrate pino-http with the logger\nconst httpLogger = pinoHttp({ logger });\n\nconst server = http.createServer((req, res) => {\n  httpLogger(req, res); // Attach pino-http to the request\n\n  if (req.url === '/') {\n    logger.info('Handling root request.');\n    res.end('Hello, World!');\n  } else if (req.url === '/error') {\n    logger.error('An example error log for internal server error.');\n    res.statusCode = 500;\n    res.end('Internal Server Error');\n  } else {\n    logger.warn('Unknown path accessed.');\n    res.statusCode = 404;\n    res.end('Not Found');\n  }\n});\n\nserver.listen(3000, () => {\n  logger.info('Server listening on http://localhost:3000');\n  console.log('To test, run this script and then use curl in another terminal:');\n  console.log('  curl http://localhost:3000');\n  console.log('  curl http://localhost:3000/error');\n  console.log('  curl http://localhost:3000/unknown');\n});","lang":"javascript","description":"Demonstrates `pino-http-print` configured as a Pino transport. It logs both HTTP requests (via `pino-http`) and general application messages from a simple Node.js HTTP server, showcasing its formatting capabilities for debugging."},"warnings":[{"fix":"Upgrade your Node.js environment to version 14 or higher. Node.js 18+ is explicitly supported and recommended for v4.x.","message":"Version 4.0.0 of `pino-http-print` officially dropped support for Node.js 12. Running on unsupported Node.js versions may lead to unexpected behavior or failures.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Always nest `pino-pretty` options under `prettyOptions`, for example: `{ all: true, prettyOptions: { ignore: 'pid,hostname' } }`.","message":"Options specific to `pino-pretty` (e.g., `ignore`, `sync`) must be encapsulated within the `prettyOptions` object when passed to `pino-http-print`, especially when `all: true` is enabled.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"To write to a file, provide a writeable stream such as `destination: fs.createWriteStream('./http.log')` or a numeric file descriptor if applicable.","message":"The `destination` option defaults to `1`, representing standard output (stdout). If you intend to redirect logs to a file or another custom stream, this option must be explicitly set.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Install the package using npm: `npm install pino-http-print` for local use, or `npm install -g pino-http-print` if planning to use it via the CLI as a legacy Pino transport.","cause":"The `pino-http-print` package is not installed as a dependency in your project or globally for CLI usage.","error":"Error: Cannot find module 'pino-http-print'"},{"fix":"Ensure you are creating your logger by passing the transport *configuration object* to `pino()`: `const transport = pino.transport({ target: 'pino-http-print', ... }); const logger = pino(transport);`","cause":"This error often occurs when `pino.transport` is called incorrectly, or when the returned transport configuration is not properly passed to the `pino()` constructor to create a logger instance.","error":"TypeError: pino is not a function"}],"ecosystem":"npm"}