Skip to content

Conversation

@dmmulroy
Copy link
Contributor

@dmmulroy dmmulroy commented Feb 3, 2026

Summary

Adds first-class Cloudflare Workers support for evlog, addressing:

Changes

  • New Workers adapter (evlog/workers):

    • initWorkersLogger(options) - initialize with stringify: false for structured objects
    • createWorkersLogger(request, options) - request-scoped logger with auto-extracted context
    • Emits objects via console[level](event) for proper platform severity mapping
  • Auto-extracted context:

    • cf-ray header as requestId
    • request.cf properties (colo, country, asn)
    • Method, path from request
  • Core changes:

    • isDev() returns false in Workers (no process/window)
    • Added stringify?: boolean option to skip JSON.stringify (for Workers)
    • Simplified getConsoleMethod to identity function

Usage

import { initWorkersLogger, createWorkersLogger } from 'evlog/workers'

initWorkersLogger({ env: { service: 'my-api' } })

export default {
  async fetch(request: Request) {
    const log = createWorkersLogger(request)
    log.set({ user: { id: '123' } })
    log.emit({ status: 200 })
    return new Response('ok')
  }
}

@vercel
Copy link

vercel bot commented Feb 3, 2026

@dmmulroy is attempting to deploy a commit to the HRCD Projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Thank you for following the naming conventions! 🙏

@dmmulroy dmmulroy changed the title feat(workers): add Cloudflare Workers adapter feat(module): add Cloudflare Workers adapter Feb 3, 2026
@dmmulroy dmmulroy force-pushed the workers-adapter branch 3 times, most recently from ae3c5b8 to 37b68bd Compare February 3, 2026 19:20
@dmmulroy dmmulroy marked this pull request as ready for review February 3, 2026 19:33
- Add initWorkersLogger() and createWorkersLogger() for CF Workers
- Auto-extract cf-ray as requestId, request.cf context (colo, country, asn)
- Add stringify option to skip JSON.stringify for Workers platform
- Fix process undefined in Workers env detection (isDev returns false)
- Simplify getConsoleMethod to identity function
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 3, 2026

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

commit: f36ca16

@HugoRCD
Copy link
Owner

HugoRCD commented Feb 3, 2026

@dmmulroy Thank you very much for the PR, so thrilled to extend evlog support to other platforms!

@vercel
Copy link

vercel bot commented Feb 3, 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 3, 2026 7:52pm

@HugoRCD HugoRCD merged commit 8c034bb into HugoRCD:main Feb 3, 2026
12 checks passed
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.

2 participants