Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

cher-ami/debug

Open more actions menu
 
 

Repository files navigation

debug

This repo is a fork of @wbe/debug

Tiny debug tool (~500 bytes) for terminal and browser inspired by visionmedia/debug API.

Motivation

@cher-ami/debug was built in order to be as light as possible for terminal and browser, as the same way as the great visionmedia/debug tool.

Installation

$ npm i @cher-ami/debug

debug node

DEBUG=* node file.js  
const debug = require("@cher-ami/debug")
debug('foo'); // "foo"

process.env.DEBUG value can be defined as a specific namespace too:

DEBUG=namespace node file.js  

Only debug function declaration with namespace declared as namespace will be printed in the console:

// add the namspace as returned function paramater
const debug = require("@cher-ami/debug")("namespace")
debug('foo'); // "namespace foo"

process.env.DEBUG value accept "one glob parameter level":

DEBUG=config:* node file.js

Every debug function declaration with namespace config:{somestring} will be logged.

debug in browser

In the same way as nodejs usage, debug is browser compatible with the same API. The only difference is we need to set the current namespace in localStorage.

Add on your browser localStorage:

localStorage.debug = "foo"

Use debug in javascript:

// es6 import
import debug from "@cher-ami/debug"
const log = debug('foo');
log("bar") // "foo bar"

// commonjs import
const debug = require("@cher-ami/debug")("foo")
debug('bar'); // "foo bar"

Examples

Install dependencies:

pnpm i

Start example:

# browser example
npm run dev:example-browser
# node example
npm run dev:example-dev

Credits

Willy Brauner

Licence

MIT

About

Tiny debug tool (~500 bytes) for terminal and browser inspired by visionmedia/debug API.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.