diff --git a/ais-structure/src/modules/helper/log.js b/ais-structure/src/modules/helper/log.js index bc65694..2c1d5e8 100644 --- a/ais-structure/src/modules/helper/log.js +++ b/ais-structure/src/modules/helper/log.js @@ -15,6 +15,10 @@ var summaryList = []; var start = {}; var detail = {}; +logger.stat = function (msg){ + logg.stat(msg); +} + logger.log = function (msg,type) { @@ -51,9 +55,9 @@ logger.startlog = function (cmdData,rawData) params : rawData.params }; start = { - session : rawData.headers, + session : "Session", cmd : cmdData, - identity : data + identity : "Identity" }; // console.log(start); @@ -73,7 +77,7 @@ logger.addSummary = function (nodeData,cmdData,resultData) logger.logSummary = function () { - var log = logg.summary(start.session, start.cmd, start.identity); + var log = logg.summary(start.session,start.cmd,start.identity); var row; for (let index = 0; index < summaryList.length; index++) { row = summaryList[index]; diff --git a/ais-structure/src/modules/helper/stats.js b/ais-structure/src/modules/helper/stats.js index 8ae5f25..d26f4e3 100644 --- a/ais-structure/src/modules/helper/stats.js +++ b/ais-structure/src/modules/helper/stats.js @@ -5,13 +5,24 @@ var log = require('../helper/log.js'); var nodeName = cfg.app_name; var stat = []; +stat.sendSACFRequest = function (toNode,cmd){ + writeStats(nodeName+" Send "+toNode+" OutRedirect SPW_"+cmd+" Request"); +}; + +stat.reciveSACFResponse = function (toNode,cmd,result){ + writeStats(nodeName+" Recive "+toNode+" OutRedirect SPW_"+cmd+" Response "+result); +}; +stat.reciveSACFBadResponse = function (toNode,cmd){ + writeStats(nodeName+" Recive "+toNode+" Bad OutRedirect SPW_"+cmd+" Response"); +}; + +stat.reciveRequest = function (method,cmd){ + writeStats(nodeName+" Recive "+method+" "+cmd+" Request"); +}; -stat.reciveRequest = function (method,cmd,pass){ - if(pass) - writeStats(nodeName+" Recive "+method+" "+cmd+" Request"); - else - writeStats(nodeName+" Recive Bad "+method+" "+cmd+" Request"); +stat.reciveBadRequest = function (method,cmd){ + writeStats(nodeName+" Recive Bad "+method+" "+cmd+" Request"); }; stat.reciveResponse = function (fromNode,cmd,result){ @@ -28,6 +39,7 @@ stat.sendResponse = function (method,cmd,result){ function writeStats(string) { log.log(string); + log.stat(string); // console.log(string); // console.log(cfg); } diff --git a/ais-structure/src/modules/vizcard/vizCard.ctrl.js b/ais-structure/src/modules/vizcard/vizCard.ctrl.js index 0e3e383..c058c93 100644 --- a/ais-structure/src/modules/vizcard/vizCard.ctrl.js +++ b/ais-structure/src/modules/vizcard/vizCard.ctrl.js @@ -10,9 +10,10 @@ var log = require('../helper/log.js'); exports.vizcard = async function (req, res, next) { var getCmd = "VIZCard"; var sendCmd = "SearchCustomer" - + var sacf = "SACF" + log.startlog(getCmd,req); - log.logDetail.addInput("Client",getCmd,"Request",req); + log.logDetail.addInput(sacf,getCmd,"Request",req); var err = validator(req,getCmd); @@ -38,8 +39,10 @@ exports.vizcard = async function (req, res, next) { moblieNo : req.query.moblieNo }; - const result = await connection.requestSoapToSPW(objectData,sendCmd,"POST"); - + log.logDetail.addOutput(sacf,sendCmd,"Request",objectData,objectData); + log.logDetail.write(); + const result = await connection.requestSoapToSACF(objectData,sendCmd,"POST"); + log.logDetail.addInput(sacf,getCmd,"Response",result,result.body); // console.log(result.err) if(typeof result.err === 'undefined'){ @@ -52,15 +55,18 @@ exports.vizcard = async function (req, res, next) { var response = responseMsg.success(req,getCmd,{resultData:resultSet,rowCount:resultSet.length}); - log.addSummary("SPW",sendCmd,response); + stats.reciveSACFResponse(sacf,sendCmd,"Success"); + log.addSummary(sacf,sendCmd,response); + log.addSummary(sacf,sendCmd,response); } - if(!response) + if(!response){ var response = responseMsg.error(req,getCmd,50000); + stats.reciveResponse(sacf,"SPW_"+sendCmd,"Error"); + } - - log.logDetail.addOutput("Client",getCmd,"Response",response,response); + log.logDetail.addOutput(sacf,getCmd,"Response",response,response); log.logDetail.write(); log.logSummary(); res.status(200).json(response); @@ -71,12 +77,12 @@ exports.vizcard = async function (req, res, next) { function validator(req,cmd) { var list = []; - list.push([true,"queryStr","commandId","int"]); - list.push([true,"queryStr","firstName","string"]); - list.push([true,"queryStr","lastName","string"]); - list.push([true,"queryStr","emailAddress","string"]); - list.push([true,"queryStr","mobileNo","string"]); - list.push([false,"queryStr","mobileNo","string"]); + // list.push([true,"queryStr","commandId","int"]); + // list.push([true,"queryStr","firstName","string"]); + // list.push([true,"queryStr","lastName","string"]); + // list.push([true,"queryStr","emailAddress","string"]); + // list.push([true,"queryStr","mobileNo","string"]); + // list.push([false,"queryStr","mobileNo","string"]); var err = validatorHelper(req,list); if(err.length > 0) -- libgit2 0.21.2