Commit c39cf9daf455a6c4b5d1132d46e468bff125bda0
1 parent
5198016b
Exists in
master
and in
1 other branch
update stat log
Showing
3 changed files
with
44 additions
and
22 deletions
Show diff stats
ais-structure/src/modules/helper/log.js
| ... | ... | @@ -15,6 +15,10 @@ var summaryList = []; |
| 15 | 15 | var start = {}; |
| 16 | 16 | var detail = {}; |
| 17 | 17 | |
| 18 | +logger.stat = function (msg){ | |
| 19 | + logg.stat(msg); | |
| 20 | +} | |
| 21 | + | |
| 18 | 22 | logger.log = function (msg,type) |
| 19 | 23 | { |
| 20 | 24 | |
| ... | ... | @@ -51,9 +55,9 @@ logger.startlog = function (cmdData,rawData) |
| 51 | 55 | params : rawData.params |
| 52 | 56 | }; |
| 53 | 57 | start = { |
| 54 | - session : rawData.headers, | |
| 58 | + session : "Session", | |
| 55 | 59 | cmd : cmdData, |
| 56 | - identity : data | |
| 60 | + identity : "Identity" | |
| 57 | 61 | }; |
| 58 | 62 | |
| 59 | 63 | // console.log(start); |
| ... | ... | @@ -73,7 +77,7 @@ logger.addSummary = function (nodeData,cmdData,resultData) |
| 73 | 77 | |
| 74 | 78 | logger.logSummary = function () |
| 75 | 79 | { |
| 76 | - var log = logg.summary(start.session, start.cmd, start.identity); | |
| 80 | + var log = logg.summary(start.session,start.cmd,start.identity); | |
| 77 | 81 | var row; |
| 78 | 82 | for (let index = 0; index < summaryList.length; index++) { |
| 79 | 83 | row = summaryList[index]; | ... | ... |
ais-structure/src/modules/helper/stats.js
| ... | ... | @@ -5,13 +5,24 @@ var log = require('../helper/log.js'); |
| 5 | 5 | var nodeName = cfg.app_name; |
| 6 | 6 | var stat = []; |
| 7 | 7 | |
| 8 | +stat.sendSACFRequest = function (toNode,cmd){ | |
| 9 | + writeStats(nodeName+" Send "+toNode+" OutRedirect SPW_"+cmd+" Request"); | |
| 10 | +}; | |
| 11 | + | |
| 12 | +stat.reciveSACFResponse = function (toNode,cmd,result){ | |
| 13 | + writeStats(nodeName+" Recive "+toNode+" OutRedirect SPW_"+cmd+" Response "+result); | |
| 14 | +}; | |
| 8 | 15 | |
| 16 | +stat.reciveSACFBadResponse = function (toNode,cmd){ | |
| 17 | + writeStats(nodeName+" Recive "+toNode+" Bad OutRedirect SPW_"+cmd+" Response"); | |
| 18 | +}; | |
| 19 | + | |
| 20 | +stat.reciveRequest = function (method,cmd){ | |
| 21 | + writeStats(nodeName+" Recive "+method+" "+cmd+" Request"); | |
| 22 | +}; | |
| 9 | 23 | |
| 10 | -stat.reciveRequest = function (method,cmd,pass){ | |
| 11 | - if(pass) | |
| 12 | - writeStats(nodeName+" Recive "+method+" "+cmd+" Request"); | |
| 13 | - else | |
| 14 | - writeStats(nodeName+" Recive Bad "+method+" "+cmd+" Request"); | |
| 24 | +stat.reciveBadRequest = function (method,cmd){ | |
| 25 | + writeStats(nodeName+" Recive Bad "+method+" "+cmd+" Request"); | |
| 15 | 26 | }; |
| 16 | 27 | |
| 17 | 28 | stat.reciveResponse = function (fromNode,cmd,result){ |
| ... | ... | @@ -28,6 +39,7 @@ stat.sendResponse = function (method,cmd,result){ |
| 28 | 39 | |
| 29 | 40 | function writeStats(string) { |
| 30 | 41 | log.log(string); |
| 42 | + log.stat(string); | |
| 31 | 43 | // console.log(string); |
| 32 | 44 | // console.log(cfg); |
| 33 | 45 | } | ... | ... |
ais-structure/src/modules/vizcard/vizCard.ctrl.js
| ... | ... | @@ -10,9 +10,10 @@ var log = require('../helper/log.js'); |
| 10 | 10 | exports.vizcard = async function (req, res, next) { |
| 11 | 11 | var getCmd = "VIZCard"; |
| 12 | 12 | var sendCmd = "SearchCustomer" |
| 13 | - | |
| 13 | + var sacf = "SACF" | |
| 14 | + | |
| 14 | 15 | log.startlog(getCmd,req); |
| 15 | - log.logDetail.addInput("Client",getCmd,"Request",req); | |
| 16 | + log.logDetail.addInput(sacf,getCmd,"Request",req); | |
| 16 | 17 | |
| 17 | 18 | var err = validator(req,getCmd); |
| 18 | 19 | |
| ... | ... | @@ -38,8 +39,10 @@ exports.vizcard = async function (req, res, next) { |
| 38 | 39 | moblieNo : req.query.moblieNo |
| 39 | 40 | }; |
| 40 | 41 | |
| 41 | - const result = await connection.requestSoapToSPW(objectData,sendCmd,"POST"); | |
| 42 | - | |
| 42 | + log.logDetail.addOutput(sacf,sendCmd,"Request",objectData,objectData); | |
| 43 | + log.logDetail.write(); | |
| 44 | + const result = await connection.requestSoapToSACF(objectData,sendCmd,"POST"); | |
| 45 | + log.logDetail.addInput(sacf,getCmd,"Response",result,result.body); | |
| 43 | 46 | // console.log(result.err) |
| 44 | 47 | |
| 45 | 48 | if(typeof result.err === 'undefined'){ |
| ... | ... | @@ -52,15 +55,18 @@ exports.vizcard = async function (req, res, next) { |
| 52 | 55 | |
| 53 | 56 | var response = responseMsg.success(req,getCmd,{resultData:resultSet,rowCount:resultSet.length}); |
| 54 | 57 | |
| 55 | - log.addSummary("SPW",sendCmd,response); | |
| 58 | + stats.reciveSACFResponse(sacf,sendCmd,"Success"); | |
| 59 | + log.addSummary(sacf,sendCmd,response); | |
| 60 | + log.addSummary(sacf,sendCmd,response); | |
| 56 | 61 | |
| 57 | 62 | } |
| 58 | 63 | |
| 59 | - if(!response) | |
| 64 | + if(!response){ | |
| 60 | 65 | var response = responseMsg.error(req,getCmd,50000); |
| 66 | + stats.reciveResponse(sacf,"SPW_"+sendCmd,"Error"); | |
| 67 | + } | |
| 61 | 68 | |
| 62 | - | |
| 63 | - log.logDetail.addOutput("Client",getCmd,"Response",response,response); | |
| 69 | + log.logDetail.addOutput(sacf,getCmd,"Response",response,response); | |
| 64 | 70 | log.logDetail.write(); |
| 65 | 71 | log.logSummary(); |
| 66 | 72 | res.status(200).json(response); |
| ... | ... | @@ -71,12 +77,12 @@ exports.vizcard = async function (req, res, next) { |
| 71 | 77 | function validator(req,cmd) |
| 72 | 78 | { |
| 73 | 79 | var list = []; |
| 74 | - list.push([true,"queryStr","commandId","int"]); | |
| 75 | - list.push([true,"queryStr","firstName","string"]); | |
| 76 | - list.push([true,"queryStr","lastName","string"]); | |
| 77 | - list.push([true,"queryStr","emailAddress","string"]); | |
| 78 | - list.push([true,"queryStr","mobileNo","string"]); | |
| 79 | - list.push([false,"queryStr","mobileNo","string"]); | |
| 80 | + // list.push([true,"queryStr","commandId","int"]); | |
| 81 | + // list.push([true,"queryStr","firstName","string"]); | |
| 82 | + // list.push([true,"queryStr","lastName","string"]); | |
| 83 | + // list.push([true,"queryStr","emailAddress","string"]); | |
| 84 | + // list.push([true,"queryStr","mobileNo","string"]); | |
| 85 | + // list.push([false,"queryStr","mobileNo","string"]); | |
| 80 | 86 | |
| 81 | 87 | var err = validatorHelper(req,list); |
| 82 | 88 | if(err.length > 0) | ... | ... |