{"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.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install pino-http-print"],"cli":null},"imports":["import { httpPrintFactory } from 'pino-http-print'","const { httpPrintFactory } = require('pino-http-print')","const transport = pino.transport({ target: 'pino-http-print', options: { ... } })"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}