Added logging middleware
This commit is contained in:
parent
8a2d98c67a
commit
1cada0f34d
2 changed files with 20 additions and 1 deletions
17
src/middleware/logging.ts
Normal file
17
src/middleware/logging.ts
Normal 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
|
||||||
|
});
|
4
src/types/fakes.d.ts
vendored
4
src/types/fakes.d.ts
vendored
|
@ -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';
|
||||||
|
|
Reference in a new issue