Byte-slice views of ansi for callers that write into &[u8] buffers
(md ANSI renderer, stack-frame colour codes). str::as_bytes is a const fn, so each constant is the same static storage as its &str twin —
no second copy of the escape bytes is emitted.
Lowercase lookup wrapper (Zig: Output.color_map.get(name)). The table
itself lives in bun_output_tags (shared with the pretty_fmt! proc-macro
so there is exactly one copy); this fn-module mirrors the Zig
ComptimeStringMap.get() surface.
Port of the std.debug subset Zig used: SourceLocation/SymbolInfo and
the frame-pointer stack unwinder (@frameAddress, MemoryAccessor,
StackIterator). Lives in bun_core (libc/std/bun_alloc only) so the crash
handler, StoredTrace, and btjs can all share one implementation.
bun.Output.Source.Stdio.restore — restore terminal to cooked mode on exit.
Thin alias over crate::output::stdio::restore (the real impl, also in
this crate); the indirection exists only because Zig spells the path both
Output.Source.Stdio.restore and Output.Stdio.restore.
Declare a scoped logger static and a local forwarding macro in one shot.
Replaces the per-file declare_scope!(X, vis); macro_rules! log { … } boilerplate.
bun.deprecated.BufferedReader(4096, File.Reader) over the process stdin.
Layout is local to bun_core; bun_sys never casts into this (it only fills
.fd during Windows startup).
RAII: disable_buffering() now, enable_buffering() on drop. Covers the
Zig Output.disableBuffering(); defer Output.enableBuffering(); pair used
around child-process exec where the child writes directly to inherited
stdio and Bun’s buffer must not interleave.
Owned ANSI-rewritten buffer; derefs to [u8] so it can be passed to
write_all(&buf) directly, and implements Display so it can be used in
write!(w, "{}", pretty_fmt::<true>("…")).
Opaque handle to a bun_sys::file::QuietWriter. bun_core treats it as a
POD blob; bun_sys casts back to the concrete type.
TODO(port): bun_sys::file::QuietWriter — size/align must match.
Input accepted by [pretty_fmt]: either a &str/&[u8] template or a
pre-formatted &fmt::Arguments<'_> (which is first rendered to a string
then <tag>-rewritten — used by Custom Inspect-style call sites that
build the template via format_args!).
Function-form of Output.debug (Zig: pub fn debug(comptime fmt, args)).
The macro form is crate::debug!; this fn variant takes a single
pre-formatted payload for call sites that build the message dynamically.
bun.Output.debugWarn — yellow debug warn: prefix to stderr in debug
builds, through the Bun output sink (so colour/redirect logic applies),
followed by an explicit flush. Zig output.zig:1189-1194.
Print a red error message. The first argument takes an error_name value, which can be either
be a Zig error, or a string or enum. The error name is converted to a string and displayed
in place of “error:”, making it useful to print things like “EACCES: Couldn’t open package.json”
Output.err(.TAG, fmt, args) with a bare string tag — e.g.
Output::err_tag("EACCES", format_args!(...)). Thin sugar over err for
call sites that already hold a fully-formatted body (not a positional
{} template).
Write buffered stdout & stderr to the terminal.
Must be called before the process exits or the buffered output will be lost.
Bun automatically calls this function in Global.exit().
bun.Output.pretty(fmt, args) — write to stdout with <tag> color expansion.
Function form: performs the <tag> → ANSI rewrite at runtime on the rendered
payload (using stdout’s colour state). Prefer the pretty! macro for literal
templates so the rewrite stays comptime.
Output.prettyErrorln — function form. Performs <tag> → ANSI rewrite on
the rendered payload (using stderr’s colour state), writes to stderr, and
appends \n if the rendered output does not already end in one. Macro
form: crate::pretty_errorln!.
Runtime <tag> → ANSI rewrite with a positional-argument tuple
substituted at each {} / {s} / {d} placeholder. Returns a Display
impl so callers can write!(w, "{}", pretty_fmt_args(fmt, true, (a, b))).
Runtime mirror of Zig prettyFmt for testing the proc-macro and for the rare
dynamic case. Produces the same byte sequence the Zig comptime version would.
bun.Output.prettyln(fmt, args) — pretty() with a trailing newline.
Function form: performs the <tag> → ANSI rewrite at runtime on the rendered
payload and appends \n if the result does not already end in one (matches
Zig output.zig:1090-1093). Prefer the prettyln! macro for literal templates.
inline(always) for the same .text-layout reason as [pretty].
Output.printError — function form. No <tag> rewrite; takes anything
Display (so both format_args!(..) and bare &str call sites compile)
and writes it to stderr without a trailing newline.
Output.printErrorln — function form (the print_errorln! macro at crate
root is the comptime-string variant). Takes anything Display so both
format_args!(..) and bare &str call sites compile; appends \n.
Single shared write path for pre-formatted bytes. Public so JS-facing
sinks (console.*, process.stdout/stderr.write) route through the same
buffering/TTY/flush semantics as the rest of the runtime instead of
bypassing to raw stdio — byte-exact for non-UTF-8 chunks (Buffer writes).