Enabling debug logs
debug
is a popular library, used by many popular frameworks, including the Express.js web framework and the Mocha test framework. debug
is a small JavaScript debugging utility based on the debugging technique used in Node.js runtime itself. It offers a straightforward and flexible way to manage debug logs, allowing you to enable or disable debugging dynamically, without altering your application code. By using debug
, you can selectively control logging for different parts of your application, making it easier to diagnose issues and understand application flow.
In the recipe, we’ll discover how to enable debug logs on an Express.js application.
Getting ready
We’ll create an Express.js web application that we can enable debug logs on:
- Create a new directory and initialize our project:
$ mkdir express-debug-app $ cd express-debug-app $ npm init --yes $ npm install express
- Now, we’ll create a single file named
server.js
:$ touch...