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 = NAMESPACE
Method 2
const Debug = const debug =
Method 3
const Debug = NAMESPACE false DebugDebug
Method 4
const Debug = NAMESPACE falseconst debug = Debugdebugconst log = Debuglog