Skip to content

Leftium/gg

Repository files navigation

gg: never use console.log() to debug again!

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.

Installation

npm add @leftium/gg

Usage

Coming soon...

Technical Details

Bundled Dependencies

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.

Updating the Bundled debug Library

When a new version of debug is released:

  1. Update debug: pnpm add [email protected]
  2. Update patch: pnpm patch [email protected] (apply changes, then pnpm patch-commit)
  3. Run the update script: ./scripts/update-debug.sh
  4. Verify patches are present: git diff src/lib/debug/src/
  5. Test dev mode: pnpm dev
  6. Test production build: pnpm prepack
  7. 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.

Inspirations

debug

A tiny JavaScript debugging utility modelled after Node.js core's debugging technique. Works in Node.js and web browsers.

q (python)

Quick and dirty debugging output for tired programmers.

IceCream (python)

Never use print() to debug again

About

gg: never use console.log() to debug again!

Resources

License

Stars

Watchers

Forks

Packages

No packages published