Skip to content

RFC: Consolidate log formatting options#267

Open
zbrydon wants to merge 7 commits intomasterfrom
expose-trimming-options
Open

RFC: Consolidate log formatting options#267
zbrydon wants to merge 7 commits intomasterfrom
expose-trimming-options

Conversation

@zbrydon
Copy link
Contributor

@zbrydon zbrydon commented Oct 20, 2025

Having a go at consolidating the log formatting options available, which will hopefully be better documented in the process 🤷

Thoughts??

@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2025

🦋 Changeset detected

Latest commit: eafcf3d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@zbrydon zbrydon changed the title Expose trimming options RFC: Consolidate log formatting options Oct 22, 2025
@zbrydon zbrydon marked this pull request as ready for review October 22, 2025 22:14
@zbrydon zbrydon requested a review from a team as a code owner October 22, 2025 22:14
@72636c 72636c self-requested a review December 7, 2025 22:17
Copy link
Member

@72636c 72636c left a comment

Choose a reason for hiding this comment

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

🙇

Comment on lines 228 to 230
maxObjectDepth,
omitHeaderNames,
redactText,
Copy link
Member

Choose a reason for hiding this comment

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

Do we intend to ship this as a breaking change for consumers that currently specify these as top-level opts, or will we have backward compatibility and a softer @deprecated notice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No strong opinions but I feel like a breaking interface change for the consumers using these formatting options isn't too aggressive 🤷

src/index.ts Outdated
Comment on lines 192 to 197
type LogFormattingOptions = FormatterOptions &
SerializerOptions & {
redact?: pino.LoggerOptions['redact'];
formatters?: pino.LoggerOptions['formatters'];
serializers?: pino.LoggerOptions['serializers'];
};
Copy link
Member

Choose a reason for hiding this comment

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

Thoughts on defining a new type here that only includes the extra options that we're bolting on top? We can then leave the built-in Pino options alone where they currently are.

src/index.ts Outdated
Comment on lines 208 to 211
omitFunctions: DEFAULT_OMIT_FUNCTIONS,
maxObjectDepth: DEFAULT_MAX_OBJECT_DEPTH,
omitHeaderNames: DEFAULT_OMIT_HEADER_NAMES,
stringLength: DEFAULT_STRING_LENGTH,
Copy link
Member

Choose a reason for hiding this comment

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

Then maybe we can define these all here / in a central place rather than them being scattered across different formatter / redact / serializer files.

src/index.ts Outdated
Eeeoh.Options<CustomLevels> &
FormatterOptions &
SerializerOptions;
Eeeoh.Options<CustomLevels> & { logFormattingOptions?: LogFormattingOptions };
Copy link
Member

Choose a reason for hiding this comment

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

I don't love logFormattingOptions given there's already https://getpino.io/#/docs/api?id=formatters-object but not confident on an alternative at the moment 😓.

STELA suggested

  • processing
  • sanitization
  • sanitize
  • transform

*/
const defaultLogFormattingOptions: LogFormattingOptions = {
omitFunctions: DEFAULT_OMIT_FUNCTIONS,
maxObjectDepth: DEFAULT_MAX_OBJECT_DEPTH,
Copy link
Member

Choose a reason for hiding this comment

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

Any idea if https://getpino.io/#/docs/api?id=depthlimit-number is better than dtrim?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pino uses https://github.com/BridgeAR/safe-stable-stringify, it seems to be proud of its performance benchmarks but dtrim doesn't publish any so 🤷

I'd been keen to swap dtrim for built in pino functionality if it's a complete replacement but dtrim provides a few more options eg omitting functions which we're making use of that pino doesn't have AFAICT.

dtrim is also seems quite simple compared to safe-stable-stringify (at a glance) and Dmitry has been receptive and responsive to our feature contributions so I think that's worth keeping in mind 🤔

src/index.ts Outdated
omitFunctions: DEFAULT_OMIT_FUNCTIONS,
maxObjectDepth: DEFAULT_MAX_OBJECT_DEPTH,
omitHeaderNames: DEFAULT_OMIT_HEADER_NAMES,
stringLength: DEFAULT_STRING_LENGTH,
Copy link
Member

Choose a reason for hiding this comment

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

Thoughts on naming here:

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.

3 participants