Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// get the status code if response written
var status = headersSent(res)
? res.statusCode
: undefined;
// get status color
var color = status >= 500 ? 31 // red
: status >= 400 ? 33 // yellow
: status >= 300 ? 36 // cyan
: status >= 200 ? 32 // green
: 0; // no color
// get colored function
var fn = developmentFormatLine[color];
if (!fn) {
// compile
// Avoid Typescript Error TS2339 (Morgan typings lacks compile)
fn = developmentFormatLine[color] = logger.compile('\x1b[0m:method :url :body :user \x1b[' +
color + 'm:status \x1b[0m:response-time ms - :res[content-length]\x1b[0m');
}
return fn(tokens, req, res);
});
//app.use(logger(':method :url :body :status :response-time ms - :res[content-length]'));