To add timestamps to all console messages with Node.js, we use the log-timestamp
package.
To install it, we run
npm install log-timestamp
Then we use it by writing
require("log-timestamp");
console.log("After log-timestamp");
to require the log-timestamp
package.
And then we call console.log
to prepend the timestamp to the log message.