logging: add status code description for redirections

This commit is contained in:
Alice Gaudon 2021-01-21 15:44:58 +01:00
parent 878f706f82
commit 2c66c66a39

View File

@ -46,7 +46,14 @@ export default class LogRequestsComponent extends ApplicationComponent {
req.log.info(requestObj); req.log.info(requestObj);
} }
} else { } else {
let logStr = `${req.ip} < ${req.method} ${req.originalUrl} - ${res.statusCode}`; let codeDescription = '';
if (res.statusCode === 301) {
codeDescription = 'Permanent redirect to ' + res.getHeader('location');
} else if (res.statusCode === 302) {
codeDescription = 'Temporary redirect to ' + res.getHeader('location');
}
let logStr = `${req.ip} < ${req.method} ${req.originalUrl} - ${res.statusCode} ${codeDescription}`;
if (err) { if (err) {
if (err instanceof Error) { if (err instanceof Error) {
if (silent) { if (silent) {