Skip to content

docs: add serializers documentation - #2494

Open
bilashcse wants to merge 3 commits into
pinojs:mainfrom
bilashcse:docs-serializers
Open

docs: add serializers documentation#2494
bilashcse wants to merge 3 commits into
pinojs:mainfrom
bilashcse:docs-serializers

Conversation

@bilashcse

Copy link
Copy Markdown

What

Adds docs/serializers.md, a dedicated page documenting the serializer interface, and links it from the docsify sidebar and the README documentation list.

Why

Closes #478. As noted there, the docs described the constraints on a serializer (synchronous, returns a JSONifiable value) but never the interface itself. @davidmarkclements suggested a serializers.md page in that thread; this is that page.

What it covers

The function signature and the value a serializer receives; that serializers apply to own top-level keys of the merging object and are skipped when the value is undefined; the errorKey / err fallback; serializing the message via messageKey; child logger inheritance and override; a pointer to pino.stdSerializers; and that Symbol.for('pino.*') is deprecated in favour of formatters.log.

Behaviour described is taken from lib/tools.js (L166-173, L203-204), lib/proto.js (L115-136) and pino.js (L111-113).

Documentation only, no code changes.

@jsumners jsumners left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serializers are documented at

pino/docs/api.md

Lines 460 to 474 in eff2b30

#### `serializers` (Object)
Default: `{err: pino.stdSerializers.err}`
An object containing functions for custom serialization of objects.
These functions should return an JSONifiable object and they
should never throw. When logging an object, each top-level property
matching the exact key of a serializer will be serialized using the defined serializer.
The serializers are applied when a property in the logged object matches a property
in the serializers. The only exception is the `err` serializer as it is also applied in case
the object is an instance of `Error`, e.g. `logger.info(new Error('kaboom'))`.
See `errorKey` option to change `err` namespace.
* See [pino.stdSerializers](#pino-stdserializers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing documentation for serializers API

2 participants