Skip to content

feat(logger): add browser entry path for client-side logging - #40

Merged
frytg merged 6 commits into
mainfrom
feat/cursor-logger-browser-entry-8c63
Jul 13, 2026
Merged

feat(logger): add browser entry path for client-side logging#40
frytg merged 6 commits into
mainfrom
feat/cursor-logger-browser-entry-8c63

Conversation

@frytg

@frytg frytg commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Investigated whether the default @frytg/logger entry can be optimized for browser use. It cannot: bundling with esbuild for --platform=browser fails on node:os, node:process, and Winston's Node dependencies.

Adds a dedicated @frytg/logger/browser entry for frontend apps (Vue, React, etc.) as a structured console replacement:

  • Avoids Node built-ins and Winston
  • Logs caller-provided fields only (level, message, source, data, error) — no server deployment env injection
  • Uses import.meta.env.DEV / MODE === 'development' for debug level and pretty-printed JSON
  • Bundles to ~3.1 KB (esbuild) vs. the default entry which does not bundle at all

Usage

// Server (unchanged)
import logger from '@frytg/logger';

// Browser
import logger from '@frytg/logger/browser';

logger.info('user signed in', {
  source: 'components/LoginForm',
  data: { method: 'oauth' },
});

How to test

  • deno run test / npx tsx --test logger/*.test.ts — all logger tests pass
  • npx esbuild logger/logger-browser.ts --bundle --platform=browser --format=esm --outfile=/tmp/logger-browser-bundle.js — bundles successfully (~3.1 KB)
  • npx esbuild logger/logger.ts --bundle --platform=browser — still fails (expected; default entry remains server-only)

Follow-ups

  • Forward browser logs to a backend endpoint in a future version
  • Consider extracting shared syslog level constants if both entries need to stay in sync long-term
Open in Web Open in Cursor 

cursoragent and others added 6 commits July 13, 2026 08:36
The default Winston-based logger cannot bundle for browser targets due to
node:os, node:process, and Winston dependencies. Add @frytg/logger/browser
as a lightweight console-based alternative with the same log event shape.

Co-authored-by: Dan <daniel@frytg.com>
Satisfies Deno lint rule requiring explicit types on public API exports.

Co-authored-by: Dan <daniel@frytg.com>
Extract GlobalContext type and avoid assigning undefined optional fields
so the browser entry type-checks under the workspace strict TS config.

Co-authored-by: Dan <daniel@frytg.com>
Drop server deployment env injection from the browser entry. The logger now
logs only caller-provided fields and uses import.meta.env dev signals for
debug level and pretty-printed output.

Co-authored-by: Dan <daniel@frytg.com>
Move syslog level definitions, level filtering, and error formatting into
shared modules used by both the Winston server logger and browser entry.

Co-authored-by: Dan <daniel@frytg.com>
Co-authored-by: Dan <daniel@frytg.com>
@frytg
frytg marked this pull request as ready for review July 13, 2026 11:28
@frytg
frytg merged commit 12757c6 into main Jul 13, 2026
16 checks passed
@frytg
frytg deleted the feat/cursor-logger-browser-entry-8c63 branch July 13, 2026 11:28
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.

2 participants