Added logging middleware

This commit is contained in:
Jake Howard 2017-02-15 20:04:46 +00:00
parent 8a2d98c67a
commit 1cada0f34d
2 changed files with 20 additions and 1 deletions

17
src/middleware/logging.ts Normal file
View file

@ -0,0 +1,17 @@
import winston from 'winston';
import expressWinston from 'express-winston';
export default expressWinston.logger({
transports: [
new winston.transports.Console({
colorize: true
})
],
meta: false,
msg: '{{ req.url }} '
.concat('status:{{ res.statusCode }} ')
.concat('useragent:{{ req.headers["user-agent"] }} ')
.concat('time:{{ res.responseTime }}ms'),
colorize: true,
statusLevels: true
});

View file

@ -2,4 +2,6 @@
declare module 'express-ip-access-control'; declare module 'express-ip-access-control';
declare module 'connect-static-file'; declare module 'connect-static-file';
declare module 'express-basic-auth' declare module 'express-basic-auth';
declare module 'winston'; // doesnt like console transport
declare module 'express-winston';