Commit bfe3e6e07aeb6c956f20eed650996f053408ee82
1 parent
dcb25139
Exists in
master
fix bug log
Showing
4 changed files
with
5 additions
and
7 deletions
Show diff stats
app.config.json
app.js
@@ -6,8 +6,6 @@ const utils = require('utils/utils'); | @@ -6,8 +6,6 @@ const utils = require('utils/utils'); | ||
6 | var log = require('./utils/log'); | 6 | var log = require('./utils/log'); |
7 | var constants = require('./utils/constants'); | 7 | var constants = require('./utils/constants'); |
8 | 8 | ||
9 | -var logg = require('./utils/commonlog').init(conf.get("configlog"),app); | ||
10 | - | ||
11 | utils.testUnit(1,2,3,4,5); | 9 | utils.testUnit(1,2,3,4,5); |
12 | // console.log(conf.get('redis.host')); | 10 | // console.log(conf.get('redis.host')); |
13 | 11 | ||
@@ -121,7 +119,7 @@ app.use(bodyParser.json()); | @@ -121,7 +119,7 @@ app.use(bodyParser.json()); | ||
121 | // app.use(passport.session()); | 119 | // app.use(passport.session()); |
122 | 120 | ||
123 | 121 | ||
124 | - | 122 | +var logg = require('./utils/commonlog').init(conf.get("configlog"),app); |
125 | app.use(function (req, res, next) { | 123 | app.use(function (req, res, next) { |
126 | // add generated request-id to session | 124 | // add generated request-id to session |
127 | //req.session.reqId = req.id; | 125 | //req.session.reqId = req.id; |
package.json
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | "test": "mocha unitTest", | 7 | "test": "mocha unitTest", |
8 | "start": "npm run test && node app.js", | 8 | "start": "npm run test && node app.js", |
9 | "gentest": "mocha unitTest && NODE_ENV=gentest node app.js", | 9 | "gentest": "mocha unitTest && NODE_ENV=gentest node app.js", |
10 | - "pullpm2": "git stash && git pull && npm install && pm2 stop hospital && pm2 start node app.js --name=hospital ", | 10 | + "pullpm2": "git stash && git pull && npm install && pm2 restart app.js --name=hospital ", |
11 | "pull": "git stash && git pull && npm install && pm2 stop hospital && npm run start " | 11 | "pull": "git stash && git pull && npm install && pm2 stop hospital && npm run start " |
12 | }, | 12 | }, |
13 | "author": "Source Code", | 13 | "author": "Source Code", |
utils/commonlog.js
@@ -628,7 +628,7 @@ log.init = function (_conf, express) { | @@ -628,7 +628,7 @@ log.init = function (_conf, express) { | ||
628 | if(typeof log.sessionID === 'function'){ | 628 | if(typeof log.sessionID === 'function'){ |
629 | sid = log.sessionID(req, res); | 629 | sid = log.sessionID(req, res); |
630 | } | 630 | } |
631 | - | 631 | + |
632 | let txtLogReq = 'INCOMING|__Method=' +req.method | 632 | let txtLogReq = 'INCOMING|__Method=' +req.method |
633 | + ' __URL=' + req.url | 633 | + ' __URL=' + req.url |
634 | + ' __Headers=' + JSON.stringify(req.headers ) | 634 | + ' __Headers=' + JSON.stringify(req.headers ) |
@@ -644,7 +644,7 @@ log.init = function (_conf, express) { | @@ -644,7 +644,7 @@ log.init = function (_conf, express) { | ||
644 | onHeaders(res, ()=>{ | 644 | onHeaders(res, ()=>{ |
645 | let txtLogRes = 'OUTGOING|__Statuscode=' + res.statusCode | 645 | let txtLogRes = 'OUTGOING|__Statuscode=' + res.statusCode |
646 | + ' __Headers=' + JSON.stringify(res._headers ) | 646 | + ' __Headers=' + JSON.stringify(res._headers ) |
647 | - + ' __Body=' + JSON.stringify(res.body ) | 647 | + + ' __Body=' + req.res.resBody |
648 | + ' __Restime=' + ( Date.now() - req._reqTimeForLog ); | 648 | + ' __Restime=' + ( Date.now() - req._reqTimeForLog ); |
649 | 649 | ||
650 | if(sid){ | 650 | if(sid){ |