pregmatch
pregmatch

Reputation: 2657

How to use nodejs debug module but only for some directory?

I have my app started with:

NODE_ENV=development DEBUG=* node-supervisor server

but that will debug everything (everything from node_modules)

How can I exclude node_modules from debug or how can i debug only one directory?

I am using: https://github.com/visionmedia/debug

Upvotes: 0

Views: 277

Answers (1)

robertklep
robertklep

Reputation: 203484

You can't debug one directory, but you can make sure that only your own code's debug messages are shown:

// your code
var debug = require('debug')('my-code');
debug('hello world');

// to only show debug messages from your own code:
DEBUG=my-code node-supervisor server

You can even create a subdivision to debug only parts of your code:

// file1.js
var debug = require('debug')('my-code:file1');

// file2.js
var debug = require('debug')('my-code:file2');

If you only want to see debug messages from file1.js:

DEBUG=my-code:file1 ...

Or show all debug messages from your code by using a wildcard:

DEBUG=my-code:* ...

Upvotes: 1

Related Questions