Skip to content

refactor(logger): overall improvements - DX, examples, business logic #16

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

Merged
merged 2 commits into from
Apr 6, 2021

Conversation

saragerion
Copy link
Contributor

@saragerion saragerion commented Mar 25, 2021

Refactor in the Logger library.

Key changes

  1. Inject context: removed environment variable. If it's injected, it's visible in the logs.
  2. AWS request ID key renamed to function_request_id
  3. Renamed all context key to start with function_*
  4. Refactor of error logic to handle better errors given with a custom key
  5. Persistent log keys: changed DX / example to use appendKey
  6. Sample rate calculation happening and set for the scope of a logger instance, not a single log item
  7. Added "refresh sample rate calculation" method
  8. Added public method for setting the sample rate value

Next steps (after this PR)

TODO: Edit repo to make it contribuiting friendly

TODO: Logger - Update test suite with missing unit tests and relevant test cases/scenario

TODO: Logger - Create docs

TODO: Logger - CI/CD pipeline for publishing
TODO: Logger - Create new package for Middy middleware

Logger examples playground

To check how the logger works, checkout in this branch:
logger-feedback-improvements

And then run the example scripts in the packages/logger folder:

cd packages/logger

npm run example:hello-world
npm run example:inject-context
npm run example:inject-context-decorator
npm run example:errors
npm run example:constructor-options
npm run example:custom-log-formatter
npm run example:child-logger
npm run example:additional-keys
npm run example:sample-rate
npm run example:persistent-attributes
npm run example:ephemeral-attributes

Checklist

Breaking change checklist

RFC issue #:

  • Migration process documented
  • Implement warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@saragerion saragerion changed the title feat(logger): overall improvements - DX, examples, business logic refactor(logger): overall improvements - DX, examples, business logic Mar 25, 2021
@saragerion saragerion merged commit aa211d1 into main Apr 6, 2021
@saragerion saragerion deleted the logger-feedback-improvements branch April 6, 2021 09:09
@saragerion saragerion self-assigned this Jun 24, 2022
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