Skip to main content

Module logs

Module logs 

Source
Expand description

bynk dev worker logs (#2474): each line a wrangler dev prints, with the stack frames that name generated TypeScript rewritten to the .bynk source line they came from.

The emitter writes a source-map v3 document beside every generated module (<file>.ts.map, ADR 0103/0569). A runtime error in a handler prints frames like at http_GET (/…/.bynk/dev/workers/shop/handlers.ts:57:11); that line is useless to someone who wrote .bynk. Rewriter looks the position up in the module’s map and puts the .bynk location in its place, so the terminal, and the editor’s log view, can link straight to the source.

The rewriting is the driver’s rather than the editor’s so the CLI benefits too. It is line-at-a-time and total: a line it does not understand, a module without a map, or a position the map does not cover is passed through as it came.

Structs§

Classifier
Classifies a stream of log lines. Wrangler tags its own messages ([ERROR], ✘, [WARNING], ▲) and prints a thrown error as Error: … followed by at … frames, so a frame inherits the level of the line it continues.
Original
A position in an original source: 1-based line and column, as editors and stack frames count.
Rewriter
Rewrites frames against the source maps under a build dir, loading each map on first use and again when it changes: a rebuild rewrites them in place.
SourceMap
A decoded source-map v3 document. Only what a frame needs: the sources and, per generated line, the segments that carry a source position.

Enums§

LogLevel
How severe a log line is, as far as wrangler dev’s output tells.

Functions§

strip_ansi
line without ANSI colour sequences (wrangler colours its output under FORCE_COLOR): an event carries text, and the editor colours it itself.