Conversation
Contributor
|
Thank you for following the naming conventions! 🙏 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
Contributor
There was a problem hiding this comment.
Pull request overview
Enhances evlog’s createRequestLogger context accumulation so that set() deep-merges nested objects (instead of overwriting them), using defu, with tests added to validate the new merge behavior.
Changes:
- Replace the
set()context update logic with adefudeep merge. - Add new unit tests covering nested and multi-level deep merge behavior for
set(). - Add
defuas a dependency and update the lockfile.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/evlog/src/logger.ts | Switch RequestLogger.set() from shallow spread to defu deep merge for context accumulation. |
| packages/evlog/test/logger.test.ts | Add tests validating deep merge behavior for nested objects in set(). |
| packages/evlog/package.json | Add defu dependency required by the new merge behavior. |
| bun.lock | Lockfile update reflecting the new dependency. |
Comments suppressed due to low confidence (1)
packages/evlog/src/logger.ts:227
set()now deep-merges intocontext, buterror()still mergeserrorContextwith a shallow spread. This can unexpectedly drop previously-set nested context (e.g.,set({ user: { id } })thenerror(err, { user: { status } })overwritesuser). Consider deep-mergingerrorContextconsistently (or clearly documenting whyerror()behaves differently).
set<T extends Record<string, unknown>>(data: T): void {
context = defu(data, context) as Record<string, unknown>
},
error(error: Error | string, errorContext?: Record<string, unknown>): void {
hasError = true
const err = typeof error === 'string' ? new Error(error) : error
context = {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #15
This pull request enhances the
createRequestLoggerfunctionality in theevlogpackage by introducing deep merging for context updates.It achieves this by integrating the
defulibrary, which allows nested objects to be merged rather than overwritten. Several new tests have been added to verify this behavior, ensuring robust handling of nested and primitive values.