Skip to content

Conversation

@HugoRCD
Copy link
Owner

@HugoRCD HugoRCD commented Feb 11, 2026

This pull request enhances the request-scoped logging capabilities in the evlog package by introducing structured support for informational and warning log messages within a request's lifecycle. It adds new logging methods, updates type definitions, and expands test coverage to ensure correct behavior and log escalation.

@vercel
Copy link

vercel bot commented Feb 11, 2026

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

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, Comment, Open in v0 Feb 12, 2026 11:00am

@github-actions
Copy link

github-actions bot commented Feb 11, 2026

Thank you for following the naming conventions! 🙏

@HugoRCD HugoRCD removed the codex label Feb 11, 2026
@HugoRCD HugoRCD self-assigned this Feb 11, 2026
@HugoRCD HugoRCD requested a review from Copilot February 11, 2026 20:57
@HugoRCD HugoRCD changed the title feat(logger): add request-scoped info() and warn() methods feat: add request-scoped info() and warn() methods Feb 11, 2026
@HugoRCD HugoRCD changed the title feat: add request-scoped info() and warn() methods feat: add request-scoped info() and warn() methods to logger Feb 11, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 11, 2026

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

commit: 3a6f5a2

Copy link
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

Adds request-scoped info() / warn() methods to the evlog request logger so intermediate messages can be captured into the final “wide event” (including final-level escalation to warn when warnings occurred), rather than emitted as standalone logs.

Changes:

  • Extend RequestLogger with info(message, context?) and warn(message, context?).
  • Introduce RequestLogEntry and store per-request entries on context.logs.
  • Add unit tests validating log capture, ordering, context merging, and warn-level escalation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/evlog/src/logger.ts Implements request-scoped info()/warn(), accumulates entries into context.logs, and escalates emitted level to warn when applicable.
packages/evlog/src/types.ts Adds RequestLogEntry and extends RequestLogger/InternalFields to type the new behavior.
packages/evlog/test/logger.test.ts Adds tests for info()/warn() capture, ordering, context merge behavior, and warn escalation at emit time.
Comments suppressed due to low confidence (1)

packages/evlog/src/types.ts:340

  • Adding logs to InternalFields makes logs a reserved key that is omitted from user-defined field types (FieldContext is Omit<T, keyof InternalFields> & InternalFields). This is a potentially breaking API change for consumers that already have a logs field in their typed request context. If backwards compatibility is a concern, consider using a less collision-prone internal name (e.g., requestLogs / _logs) or clearly documenting logs as reserved in the public API/changelog.
export interface InternalFields {
  status?: number
  service?: string
  logs?: RequestLogEntry[]
}

/**
 * Request-scoped log entry captured during a request lifecycle.
 */
export interface RequestLogEntry {
  level: 'info' | 'warn'
  message: string
  timestamp: string
}

/**
 * Resolved context type for logger methods.
 * User fields are deeply partial (matching deep merge behavior) with internal
 * field keys omitted to avoid intersection conflicts, then internal fields
 * are added back with their canonical types.
 */
export type FieldContext<T extends object = Record<string, unknown>> =
  DeepPartial<Omit<T, keyof InternalFields>> & InternalFields


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

packages/evlog/src/logger.ts:304

  • info()/warn() explicitly strip a logs key from the provided context to avoid clobbering accumulated request logs, but other entry points can still overwrite context.logs (e.g. set(), error(..., context), and emit(overrides) accept FieldContext which now includes logs). Consider also omitting/ignoring logs in those merge paths and/or tightening parameter types (e.g. Omit<FieldContext<T>, 'logs'>) so request log accumulation can’t be accidentally replaced.
  }

  return {
    set(data: FieldContext<T>): void {
      context = deepDefaults(data as Record<string, unknown>, context) as Record<string, unknown>
    },

    error(error: Error | string, errorContext?: FieldContext<T>): void {
      hasError = true
      const err = typeof error === 'string' ? new Error(error) : error

      const errorData = {
        ...(errorContext as Record<string, unknown>),
        error: {
          name: err.name,
          message: err.message,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +317 to +330
: T

/**
* Fields set internally by the evlog plugin (status, service, etc.).
* These are always accepted by `set()` regardless of the user-defined field type.
*/
export interface InternalFields {
status?: number
service?: string
logs?: RequestLogEntry[]
}

/**
* Request-scoped log entry captured during a request lifecycle.
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

logs is added to InternalFields, which makes logs a reserved key in FieldContext (it gets omitted from user-defined field types). This is a potentially breaking TypeScript change for consumers that previously had their own logs field in their request context. Consider renaming this internal field to something less collision-prone (e.g. requestLogs) or otherwise documenting/mitigating the reserved-key change.

Copilot uses AI. Check for mistakes.
@HugoRCD HugoRCD merged commit bae9521 into main Feb 12, 2026
11 checks passed
@HugoRCD HugoRCD deleted the codex/linear-mention-evl-73-feature]-add-info-and-warn branch February 12, 2026 11:02
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