pino-std-serializers
A collection of standard object serializers for Pino
Last updated 2 years ago by jsumners .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install pino-std-serializers 
SYNC missed versions from official npm registry.

pino-std-serializers  CI

This module provides a set of standard object serializers for the Pino logger.

Serializers

exports.err(error)

Serializes an Error like object. Returns an object:

{
  type: 'string', // The name of the object's constructor.
  message: 'string', // The supplied error message.
  stack: 'string', // The stack when the error was generated.
  raw: Error  // Non-enumerable, i.e. will not be in the output, original
              // Error object. This is available for subsequent serializers
              // to use.
}

Any other extra properties, e.g. statusCode, that have been attached to the object will also be present on the serialized object.

exports.mapHttpResponse(response)

Used internally by Pino for general response logging. Returns an object:

{
  res: {}
}

Where res is the response as serialized by the standard response serializer.

exports.mapHttpRequest(request)

Used internall by Pino for general request logging. Returns an object:

{
  req: {}
}

Where req is the request as serialized by the standard request serializer.

exports.req(request)

The default request serializer. Returns an object:

{
  id: 'string', // Defaults to `undefined`, unless there is an `id` property 
                // already attached to the `request` object or to the `request.info`
                // object. Attach a synchronous function
                // to the `request.id` that returns an identifier to have
                // the value filled.
  method: 'string',
  url: 'string', // the request pathname (as per req.url in core HTTP)
  query: 'object', // the request query (as per req.query in express or hapi)
  params: 'object', // the request params (as per req.params in express or hapi)
  headers: Object, // a reference to the `headers` object from the request
                   // (as per req.headers in core HTTP)
  remoteAddress: 'string',
  remotePort: Number,
  raw: Object // Non-enumerable, i.e. will not be in the output, original
              // request object. This is available for subsequent serializers
              // to use. In cases where the `request` input already has 
              // a `raw` property this will replace the original `request.raw`
              // property
}

exports.res(response)

The default response serializer. Returns an object:

{
  statusCode: Number, // Response status code, will be null before headers are flushed
  headers: Object, // The headers to be sent in the response.
  raw: Object // Non-enumerable, i.e. will not be in the output, original
              // response object. This is available for subsequent serializers
              // to use.
}

exports.wrapErrorSerializer(customSerializer)

A utility method for wrapping the default error serializer. This allows custom serializers to work with the already serialized object.

The customSerializer accepts one parameter — the newly serialized error object — and returns the new (or updated) error object.

exports.wrapRequestSerializer(customSerializer)

A utility method for wrapping the default request serializer. This allows custom serializers to work with the already serialized object.

The customSerializer accepts one parameter — the newly serialized request object — and returns the new (or updated) request object.

exports.wrapResponseSerializer(customSerializer)

A utility method for wrapping the default response serializer. This allows custom serializers to work with the already serialized object.

The customSerializer accepts one parameter — the newly serialized response object — and returns the new (or updated) response object.

License

MIT License

Current Tags

  • 6.1.0                                ...           latest (2 years ago)

28 Versions

  • 6.1.0                                ...           2 years ago
  • 6.0.0                                ...           2 years ago
  • 5.6.0                                ...           2 years ago
  • 5.5.0                                ...           2 years ago
  • 5.4.0                                ...           2 years ago
  • 5.3.0                                ...           3 years ago
  • 5.2.0                                ...           3 years ago
  • 5.1.1                                ...           3 years ago
  • 5.1.0                                ...           3 years ago
  • 5.0.0                                ...           3 years ago
  • 4.0.0                                ...           4 years ago
  • 3.2.0                                ...           4 years ago
  • 3.1.1                                ...           4 years ago
  • 3.1.0                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.5.0                                ...           4 years ago
  • 2.4.2                                ...           6 years ago
  • 2.4.1                                ...           6 years ago
  • 2.4.0                                ...           6 years ago
  • 2.3.0                                ...           6 years ago
  • 2.2.1                                ...           6 years ago
  • 2.2.0                                ...           6 years ago
  • 2.1.0                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 1.2.0                                ...           7 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (7)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |