gg() is a logger/debugger with several advantages:
- Annotated with automatic namespace based on source file and calling function.
- Each namespace gets a unique color for easier visual parsing.
- Simple syntax with wildcards to filter/hide debug output at runtime.
- Millisecond diff (timestamps) for each namespace.
- Can be inserted into the middle of expressions (returns the value of the first argument).
- Can output a link that opens the source file in your editor (like VS Code).
- Simple to disable (turn all loggs into NOP's for production).
- Diagnostics/hints in dev console & terminal to help install and configure correctly.
- Faster to type.
npm add @leftium/gg
Coming soon...
This library includes a patched version of the debug package. The patch reformats the output to display time diffs before the namespace for better readability:
Standard debug output:
gg:routes/+page.svelte +123ms
Patched output (this library):
+123ms gg:routes/+page.svelte
The patched debug library is bundled directly into the distribution, so consumers automatically get the correct behavior without needing to install or patch debug themselves.
When a new version of debug is released:
- Update debug:
pnpm add [email protected] - Update patch:
pnpm patch [email protected](apply changes, thenpnpm patch-commit) - Run the update script:
./scripts/update-debug.sh - Verify patches are present:
git diff src/lib/debug/src/ - Test dev mode:
pnpm dev - Test production build:
pnpm prepack - Commit changes:
git commit -am "Update bundled debug to x.x.x"
The patch is maintained in patches/[email protected] for reference.
Note: debug is kept in dependencies (not devDependencies) to support both dev and production modes.
A tiny JavaScript debugging utility modelled after Node.js core's debugging technique. Works in Node.js and web browsers.
Quick and dirty debugging output for tired programmers.
Never use print() to debug again