Issue
I am new to node.js and I am trying to move away from using console.log for debugging everything. I am trying to use
debug("test message")
instead of console.log for everything.
I installed the debug npm package, and it instructed me to:
set DEBUG=* node server.js
But, with my express package, I get the following:
The app message in blue is the only relevant message to me since I am trying to use that instead of console.log. How can I get rid of these express logs? Do you think at some point they would be important?
Solution
you can use it like
dbg=debug('myserver:app')
and output messages with
dbg('A new message')
also to output only those messages that you want
set DEBUG=myserver:app node server.js
you can also exclude with -
or include like myserver:app,express:*
with DEBUG environmental variable you can specify what to output or no. more information https://www.npmjs.com/package/debug check the wildcards and examples