pino-std-serializers
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',
message: 'string',
stack: 'string',
raw: Error
}
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 and object:
{
id: 'string',
method: 'string',
url: 'string',
query: 'object',
params: 'object',
headers: Object,
remoteAddress: 'string',
remotePort: Number,
raw: Object
}
exports.res(response)
The default response
serializer. Returns an object:
{
statusCode: Number,
headers: Object,
raw: Object
}
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