nodejs-debug

1.0.2 • Public • Published

nodejs-debug

Introdution

I used debug in most of my projects, it's a very good library. But there are some limitations as I have to write a new library to serve my projects. It is based on debug

Difference

nodejs-debug works similarly to debug but:

  • Automatically adding :error after namespace when input intanceof Error object
  • Added a log method to instead of console.log, the difference for console.log is that it supports namespace (that's all)
  • Fixes 'Automatic enable debugging on other modules that use debug library' when run (DEBUG = * node [file])
  • Automatically define color for namespace based on namespace and module.parent.filename, avoid color duplication problem when namespace is the same.

Installation

npm install nodejs-debug

Run

DEBUG=* node index.js

Setup in app

Method 1

const debug = require('nodejs-debug')(NAMESPACE)
 
debug('message')

Method 2

const Debug = require('nodejs-debug')
const debug = Debug(NAMESPACE)
 
debug('message')

Method 3

const Debug = require('nodejs-debug')(NAMESPACE, false)
 
Debug.debug('message')
Debug.log('message')

Method 4

const Debug = require('nodejs-debug')(NAMESPACE, false)
const debug = Debug.debug.bind(Debug)
const log = Debug.log.bind(Debug)
 
debug('message')
log('message')

Package Sidebar

Install

npm i nodejs-debug

Weekly Downloads

2

Version

1.0.2

License

MIT

Last publish

Collaborators