diff --git a/src/middleware/logging.ts b/src/middleware/logging.ts new file mode 100644 index 0000000..c30a728 --- /dev/null +++ b/src/middleware/logging.ts @@ -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 +}); diff --git a/src/types/fakes.d.ts b/src/types/fakes.d.ts index 5089d78..c2a77d8 100644 --- a/src/types/fakes.d.ts +++ b/src/types/fakes.d.ts @@ -2,4 +2,6 @@ declare module 'express-ip-access-control'; 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';