Complete the code to log an informational message using Express's logger.
app.use((req, res, next) => { console.[1]('Request received'); next(); });The info log level is used for general informational messages like requests received.
Complete the code to log a warning when a deprecated API endpoint is accessed.
app.get('/old-endpoint', (req, res) => { console.[1]('Deprecated endpoint used'); res.send('Deprecated'); });
The warn level is appropriate for deprecated features to alert developers without stopping the app.
Fix the error in the code to log an error message when a server error occurs.
app.use((err, req, res, next) => { console.[1]('Server error:', err); res.status(500).send('Error'); });The error log level is used to log serious problems like server errors.
Fill both blanks to log detailed debugging information only when debugging is enabled.
if (process.env.DEBUG) { console.[1]('Debug info:', [2]); }
Use debug level for detailed logs and req to show request details.
Fill all three blanks to create a middleware that logs errors and warns about slow responses.
app.use((req, res, next) => { const start = Date.now(); res.on('finish', () => { const duration = Date.now() - [1]; if (duration > [2]) { console.[3](`Slow response: ${duration}ms`); } }); next(); });The variable start holds the start time, 1000 ms is the threshold, and warn logs slow responses as warnings.