1.0.2 • Published 8 years ago
nodejs-debug v1.0.2
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
:errorafter namespace wheninput intanceof Errorobject - Added a
logmethod to instead ofconsole.log, the difference forconsole.logis 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-debugRun
DEBUG=* node index.jsSetup 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')