Skip to content

feat: use defu to compose wide-events#28

Merged
HugoRCD merged 2 commits intomainfrom
feat/defu
Feb 2, 2026
Merged

feat: use defu to compose wide-events#28
HugoRCD merged 2 commits intomainfrom
feat/defu

Conversation

@HugoRCD
Copy link
Copy Markdown
Owner

@HugoRCD HugoRCD commented Feb 2, 2026

Resolves #15

This pull request enhances the createRequestLogger functionality in the evlog package by introducing deep merging for context updates.
It achieves this by integrating the defu library, 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.

@HugoRCD HugoRCD requested a review from Copilot February 2, 2026 10:15
@HugoRCD HugoRCD self-assigned this Feb 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 2, 2026

Thank you for following the naming conventions! 🙏

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, Comment Feb 2, 2026 10:26am

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 2, 2026

npm i https://pkg.pr.new/evlog@28

commit: 26b5862

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 a defu deep merge.
  • Add new unit tests covering nested and multi-level deep merge behavior for set().
  • Add defu as 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 into context, but error() still merges errorContext with a shallow spread. This can unexpectedly drop previously-set nested context (e.g., set({ user: { id } }) then error(err, { user: { status } }) overwrites user). Consider deep-merging errorContext consistently (or clearly documenting why error() 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.

Comment thread packages/evlog/src/logger.ts
Comment thread packages/evlog/test/logger.test.ts
@HugoRCD HugoRCD merged commit f44e87d into main Feb 2, 2026
12 checks passed
@HugoRCD HugoRCD deleted the feat/defu branch February 2, 2026 10:28
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.

[feature] Deep Merge on useLogger().set().

2 participants