Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pino-std-serializers

Package Overview
Dependencies
Maintainers
4
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-std-serializers

A collection of standard object serializers for Pino

  • 5.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.1M
decreased by-4.71%
Maintainers
4
Weekly downloads
 
Created

What is pino-std-serializers?

The pino-std-serializers package provides standard serializers for the Pino logging library. These serializers help in formatting various types of JavaScript objects and values into a more structured and readable format for logging purposes. This is particularly useful in applications where consistent log formats are necessary for debugging and monitoring.

What are pino-std-serializers's main functionalities?

req (HTTP request serializer)

Serializes HTTP request objects to log them in a structured format, including method, url, headers, and other relevant information.

const pino = require('pino');
const stdSerializers = require('pino-std-serializers');
const logger = pino({
  serializers: {
    req: stdSerializers.req
  }
});

http.createServer((req, res) => {
  logger.info({req}, 'request received');
  res.end('hello world');
}).listen(3000);

res (HTTP response serializer)

Serializes HTTP response objects to capture and log status code, headers, and other response attributes.

const pino = require('pino');
const stdSerializers = require('pino-std-serializers');
const logger = pino({
  serializers: {
    res: stdSerializers.res
  }
});

http.createServer((req, res) => {
  res.on('finish', () => {
    logger.info({res}, 'response sent');
  });
  res.end('hello world');
}).listen(3000);

err (Error serializer)

Provides a way to serialize error objects, including the message, stack trace, and other properties, which aids in debugging and error tracking.

const pino = require('pino');
const stdSerializers = require('pino-std-serializers');
const logger = pino({
  serializers: {
    err: stdSerializers.err
  }
});

try {
  throw new Error('Something went wrong');
} catch (err) {
  logger.error({err}, 'error occurred');
}

Other packages similar to pino-std-serializers

Keywords

FAQs

Package last updated on 24 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc