Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add bunyamin.useTransform() for log fields customization #16

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

noomorph
Copy link
Collaborator

@noomorph noomorph commented Apr 2, 2024

Introduce the useTransform method to allow users to easily customize and transform log fields before they are passed to the underlying logger.

The useTransform method leverages the existing transformFields mechanism and provides a convenient way for users to modify log fields. For example, users can now call:

bunyamin.useTransform((fields) => ({ ...fields, err: serializeError(fields.err) }))

This feature enhances flexibility and enables users to adapt the logging output to their specific needs, such as serializing error objects, adding custom fields, or modifying existing fields.

The useTransform method can be chained, allowing users to compose multiple transformation functions. The transformations will be applied in the order they are defined.

bunyamin.useTransform((fields) => ({ ...fields, x: 3 }))
bunyamin.useTransform((fields) => ({ ...fields, x: fields.x * 3 }))
// { x: 9 }

@noomorph noomorph changed the title feat: bunyamin.useTransform feat: add bunyamin.useTransform() for log fields customization Apr 2, 2024
@noomorph noomorph merged commit a19df84 into master Apr 2, 2024
3 checks passed
@noomorph noomorph deleted the feat/use-transform branch April 2, 2024 05:54
Copy link

github-actions bot commented Apr 2, 2024

🎉 This PR is included in version 1.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant