Giter Club home page Giter Club logo

debug's Introduction

@wbe/debug

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

Motivation

@wbe/debug was built in order to be as light as possible and for the personal challenge to coding a debugger, for terminal and browser, as the same way as the great visionmedia/debug tool.

Installation

$ npm install -s @wbe/debug

debug node

DEBUG=* node file.js  
const debug = require("@wbe/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("@wbe/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 printed.

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:

const debug = require("@wbe/debug")("foo")
debug('bar'); // "foo bar"

// or with es6 import
import debug from "@wbe/debug"
const log = debug('foo');

log("bar") // "foo bar"

Example

Test browser example:

npm i && npm run dev:browser

Test node example:

npm i && npm run dev:node

Credits

Willy Brauner

Licence

MIT

debug's People

Contributors

willybrauner avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.