5. You want to add structured logging in Express that includes level, message, timestamp, and requestId from middleware. Which code snippet correctly logs this info?
hard
A. app.use((req, res, next) => {
console.log(JSON.stringify({ level: 'info', message: 'Request received', timestamp: new Date().toISOString(), requestId: req.id }));
next();
});
B. app.use((req, res, next) => {
console.log({ level: 'info', message: 'Request received', timestamp: new Date(), requestId: req.id });
next();
});
C. app.use((req, res, next) => {
console.log('Request received at ' + new Date() + ' with id ' + req.id);
next();
});
D. app.use((req, res, next) => {
console.log(JSON.stringify(level: 'info', message: 'Request received', timestamp: new Date().toISOString(), requestId: req.id));
next();
});