nodejs-debug
v1.0.2
Published
### Introdution I used [debug](https://github.com/visionmedia/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](https://github.com/visionme
Downloads
7
Maintainers
Readme
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 wheninput intanceof Error
object - Added a
log
method to instead ofconsole.log
, the difference forconsole.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')