feat(logger): add browser entry path for client-side logging - #40
Merged
Conversation
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>
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.
Summary
Investigated whether the default
@frytg/loggerentry can be optimized for browser use. It cannot: bundling with esbuild for--platform=browserfails onnode:os,node:process, and Winston's Node dependencies.Adds a dedicated
@frytg/logger/browserentry for frontend apps (Vue, React, etc.) as a structuredconsolereplacement:level,message,source,data,error) — no server deployment env injectionimport.meta.env.DEV/MODE === 'development'for debug level and pretty-printed JSONUsage
How to test
deno run test/npx tsx --test logger/*.test.ts— all logger tests passnpx 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