Commit bfe3e6e07aeb6c956f20eed650996f053408ee82

Authored by sumatek
1 parent dcb25139
Exists in master

fix bug log

app.config.json
... ... @@ -25,7 +25,7 @@
25 25 "file" : true
26 26 },
27 27 "detail" : {
28   - "time" : 2,
  28 + "time" : 15,
29 29 "size" : null,
30 30 "path" : "./logs/detail",
31 31 "console" : false,
... ...
app.js
... ... @@ -6,8 +6,6 @@ const utils = require('utils/utils');
6 6 var log = require('./utils/log');
7 7 var constants = require('./utils/constants');
8 8  
9   -var logg = require('./utils/commonlog').init(conf.get("configlog"),app);
10   -
11 9 utils.testUnit(1,2,3,4,5);
12 10 // console.log(conf.get('redis.host'));
13 11  
... ... @@ -121,7 +119,7 @@ app.use(bodyParser.json());
121 119 // app.use(passport.session());
122 120  
123 121  
124   -
  122 +var logg = require('./utils/commonlog').init(conf.get("configlog"),app);
125 123 app.use(function (req, res, next) {
126 124 // add generated request-id to session
127 125 //req.session.reqId = req.id;
... ...
package.json
... ... @@ -7,7 +7,7 @@
7 7 "test": "mocha unitTest",
8 8 "start": "npm run test && node app.js",
9 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 11 "pull": "git stash && git pull && npm install && pm2 stop hospital && npm run start "
12 12 },
13 13 "author": "Source Code",
... ...
utils/commonlog.js
... ... @@ -628,7 +628,7 @@ log.init = function (_conf, express) {
628 628 if(typeof log.sessionID === 'function'){
629 629 sid = log.sessionID(req, res);
630 630 }
631   -
  631 +
632 632 let txtLogReq = 'INCOMING|__Method=' +req.method
633 633 + ' __URL=' + req.url
634 634 + ' __Headers=' + JSON.stringify(req.headers )
... ... @@ -644,7 +644,7 @@ log.init = function (_conf, express) {
644 644 onHeaders(res, ()=>{
645 645 let txtLogRes = 'OUTGOING|__Statuscode=' + res.statusCode
646 646 + ' __Headers=' + JSON.stringify(res._headers )
647   - + ' __Body=' + JSON.stringify(res.body )
  647 + + ' __Body=' + req.res.resBody
648 648 + ' __Restime=' + ( Date.now() - req._reqTimeForLog );
649 649  
650 650 if(sid){
... ...