Commit e2039477089b2cd9a19d746e3c38f6bbdf90070f
1 parent
095c6af4
Exists in
master
and in
1 other branch
update log
Showing
4 changed files
with
55 additions
and
22 deletions
Show diff stats
ais-structure/src/modules/helper/connection.js
| @@ -3,6 +3,7 @@ var cfg = require('../../config/config.js').get(env); | @@ -3,6 +3,7 @@ var cfg = require('../../config/config.js').get(env); | ||
| 3 | var stats = require('../helper/stats.js'); | 3 | var stats = require('../helper/stats.js'); |
| 4 | var request = require('request'); | 4 | var request = require('request'); |
| 5 | var messageSOAP = require('../helper/messageSOAP.js'); | 5 | var messageSOAP = require('../helper/messageSOAP.js'); |
| 6 | +var log = require('../helper/log.js'); | ||
| 6 | 7 | ||
| 7 | var connection = []; | 8 | var connection = []; |
| 8 | 9 | ||
| @@ -15,6 +16,9 @@ connection.requestSoapToSACF = async function (soap,cmd,myMethod) { | @@ -15,6 +16,9 @@ connection.requestSoapToSACF = async function (soap,cmd,myMethod) { | ||
| 15 | method : myMethod | 16 | method : myMethod |
| 16 | } | 17 | } |
| 17 | 18 | ||
| 19 | + log.logDetail.addOutput(cfg.service.SACF.Name,cmd,"Request",params.body,soap); | ||
| 20 | + log.logDetail.write(); | ||
| 21 | + | ||
| 18 | return asyncRequest(params,cmd,cfg.service.SACF.Name); | 22 | return asyncRequest(params,cmd,cfg.service.SACF.Name); |
| 19 | }; | 23 | }; |
| 20 | connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | 24 | connection.requestJsonToD01 = async function (obj,cmd,myMethod) { |
ais-structure/src/modules/helper/log.js
| @@ -63,46 +63,67 @@ logger.startlog = function (cmdData,rawData) | @@ -63,46 +63,67 @@ logger.startlog = function (cmdData,rawData) | ||
| 63 | // console.log(start); | 63 | // console.log(start); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | -logger.addSummary = function (nodeData,cmdData,resultData) | 66 | +logger.addSuccessSummary = function (nodeData,cmdData,resultData) |
| 67 | { | 67 | { |
| 68 | summary = { | 68 | summary = { |
| 69 | node : nodeData, | 69 | node : nodeData, |
| 70 | cmd : cmdData, | 70 | cmd : cmdData, |
| 71 | resultCode : resultData.resultCode, | 71 | resultCode : resultData.resultCode, |
| 72 | - resultDesc : resultData.developerMessage | 72 | + resultDesc : resultData.developerMessage, |
| 73 | + type : "success" | ||
| 73 | }; | 74 | }; |
| 74 | summaryList.push(summary); | 75 | summaryList.push(summary); |
| 75 | // console.log(summary); | 76 | // console.log(summary); |
| 76 | } | 77 | } |
| 77 | 78 | ||
| 78 | -logger.logSummary = function () | 79 | +logger.addErrorSummary = function (nodeData,cmdData,resultData) |
| 80 | +{ | ||
| 81 | + summary = { | ||
| 82 | + node : nodeData, | ||
| 83 | + cmd : cmdData, | ||
| 84 | + resultCode : resultData.resultCode, | ||
| 85 | + resultDesc : resultData.developerMessage, | ||
| 86 | + type : "error" | ||
| 87 | + }; | ||
| 88 | + summaryList.push(summary); | ||
| 89 | + // console.log(summary); | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +logger.logSummary = function (response) | ||
| 79 | { | 93 | { |
| 80 | var log = logg.summary(start.session,start.cmd,start.identity); | 94 | var log = logg.summary(start.session,start.cmd,start.identity); |
| 81 | var row; | 95 | var row; |
| 82 | for (let index = 0; index < summaryList.length; index++) { | 96 | for (let index = 0; index < summaryList.length; index++) { |
| 83 | row = summaryList[index]; | 97 | row = summaryList[index]; |
| 84 | - log.addSuccessBlock(row.node,row.cmd,row.resultCode,row.resultDesc); | 98 | + if(row.type === "success"){ |
| 99 | + log.addSuccessBlock(row.node,row.cmd,row.resultCode,row.resultDesc); | ||
| 100 | + } else { | ||
| 101 | + log.addErrorBlock(row.node,row.cmd,row.resultCode,row.resultDesc); | ||
| 102 | + } | ||
| 85 | } | 103 | } |
| 86 | - log.end(row.resultCode,row.resultDesc) | 104 | + log.end(response.resultCode,response.developerMessage) |
| 87 | } | 105 | } |
| 88 | 106 | ||
| 89 | var addlogDetailData = function(inputType,node,cmd,type,rawData,data){ | 107 | var addlogDetailData = function(inputType,node,cmd,type,rawData,data){ |
| 90 | if(inputType == 'input') | 108 | if(inputType == 'input') |
| 91 | { | 109 | { |
| 92 | - if(!data) | 110 | + if(rawData) |
| 93 | { | 111 | { |
| 94 | - var data = { | 112 | + var raw = { |
| 95 | body : rawData.body, | 113 | body : rawData.body, |
| 96 | query : rawData.query, | 114 | query : rawData.query, |
| 97 | params : rawData.params | 115 | params : rawData.params |
| 98 | }; | 116 | }; |
| 117 | + } else { | ||
| 118 | + var raw = { | ||
| 119 | + }; | ||
| 99 | } | 120 | } |
| 100 | 121 | ||
| 101 | detail.input = { | 122 | detail.input = { |
| 102 | node : node, | 123 | node : node, |
| 103 | cmd : cmd, | 124 | cmd : cmd, |
| 104 | type : type, | 125 | type : type, |
| 105 | - rawData : data, | 126 | + rawData : raw, |
| 106 | data : data | 127 | data : data |
| 107 | }; | 128 | }; |
| 108 | 129 |
ais-structure/src/modules/helper/stats.js
| @@ -5,6 +5,7 @@ var log = require('../helper/log.js'); | @@ -5,6 +5,7 @@ var log = require('../helper/log.js'); | ||
| 5 | var nodeName = cfg.app_name; | 5 | var nodeName = cfg.app_name; |
| 6 | var stat = []; | 6 | var stat = []; |
| 7 | 7 | ||
| 8 | +// CMF => SACF | ||
| 8 | stat.sendSACFRequest = function (toNode,cmd){ | 9 | stat.sendSACFRequest = function (toNode,cmd){ |
| 9 | writeStats(nodeName+" Send "+toNode+" OutRedirect SPW_"+cmd+" Request"); | 10 | writeStats(nodeName+" Send "+toNode+" OutRedirect SPW_"+cmd+" Request"); |
| 10 | }; | 11 | }; |
| @@ -17,6 +18,7 @@ stat.reciveSACFBadResponse = function (toNode,cmd){ | @@ -17,6 +18,7 @@ stat.reciveSACFBadResponse = function (toNode,cmd){ | ||
| 17 | writeStats(nodeName+" Recive "+toNode+" Bad OutRedirect SPW_"+cmd+" Response"); | 18 | writeStats(nodeName+" Recive "+toNode+" Bad OutRedirect SPW_"+cmd+" Response"); |
| 18 | }; | 19 | }; |
| 19 | 20 | ||
| 21 | +//client => CMF | ||
| 20 | stat.reciveRequest = function (method,cmd){ | 22 | stat.reciveRequest = function (method,cmd){ |
| 21 | writeStats(nodeName+" Recive "+method+" "+cmd+" Request"); | 23 | writeStats(nodeName+" Recive "+method+" "+cmd+" Request"); |
| 22 | }; | 24 | }; |
| @@ -25,18 +27,28 @@ stat.reciveBadRequest = function (method,cmd){ | @@ -25,18 +27,28 @@ stat.reciveBadRequest = function (method,cmd){ | ||
| 25 | writeStats(nodeName+" Recive Bad "+method+" "+cmd+" Request"); | 27 | writeStats(nodeName+" Recive Bad "+method+" "+cmd+" Request"); |
| 26 | }; | 28 | }; |
| 27 | 29 | ||
| 28 | -stat.reciveResponse = function (fromNode,cmd,result){ | ||
| 29 | - writeStats(nodeName+" Recive "+fromNode+" "+cmd+" Response "+result); | 30 | +stat.sendResponse = function (method,cmd,result){ |
| 31 | + writeStats(nodeName+" Send "+method+" "+cmd+" Response "+result); | ||
| 30 | }; | 32 | }; |
| 31 | 33 | ||
| 34 | +//CMF => other server [in REST api] | ||
| 35 | + | ||
| 36 | + | ||
| 37 | +//CMF => other server | ||
| 32 | stat.sendRequest = function (toNode,cmd){ | 38 | stat.sendRequest = function (toNode,cmd){ |
| 33 | writeStats(nodeName+" Send "+toNode+" "+cmd+" Request"); | 39 | writeStats(nodeName+" Send "+toNode+" "+cmd+" Request"); |
| 34 | }; | 40 | }; |
| 35 | 41 | ||
| 36 | -stat.sendResponse = function (method,cmd,result){ | ||
| 37 | - writeStats(nodeName+" Send "+method+" "+cmd+" Response "+result); | 42 | +stat.reciveResponse = function (fromNode,cmd,result){ |
| 43 | + writeStats(nodeName+" Recive "+fromNode+" "+cmd+" Response "+result); | ||
| 38 | }; | 44 | }; |
| 39 | 45 | ||
| 46 | +stat.reciveBadResponse = function (fromNode,cmd,result){ | ||
| 47 | + writeStats(nodeName+" Recive "+fromNode+" Bad "+cmd+" Response "); | ||
| 48 | +}; | ||
| 49 | + | ||
| 50 | + | ||
| 51 | + | ||
| 40 | function writeStats(string) { | 52 | function writeStats(string) { |
| 41 | log.log(string); | 53 | log.log(string); |
| 42 | log.stat(string); | 54 | log.stat(string); |
ais-structure/src/modules/vizcard/vizCard.ctrl.js
| @@ -13,16 +13,14 @@ exports.vizcard = async function (req, res, next) { | @@ -13,16 +13,14 @@ exports.vizcard = async function (req, res, next) { | ||
| 13 | var sacf = "SACF" | 13 | var sacf = "SACF" |
| 14 | 14 | ||
| 15 | log.startlog(getCmd,req); | 15 | log.startlog(getCmd,req); |
| 16 | - log.logDetail.addInput(sacf,getCmd,"Request",req); | 16 | + log.logDetail.addInput(sacf,getCmd,"Request",req,req.body); |
| 17 | 17 | ||
| 18 | var err = validator(req,getCmd); | 18 | var err = validator(req,getCmd); |
| 19 | 19 | ||
| 20 | if(err.length > 0) | 20 | if(err.length > 0) |
| 21 | { | 21 | { |
| 22 | - log.log(err); | ||
| 23 | - | 22 | + log.log(err); |
| 24 | var response = responseMsg.error(req,getCmd,40300); | 23 | var response = responseMsg.error(req,getCmd,40300); |
| 25 | - | ||
| 26 | res.status(200).json(response); | 24 | res.status(200).json(response); |
| 27 | }else | 25 | }else |
| 28 | { | 26 | { |
| @@ -39,8 +37,6 @@ exports.vizcard = async function (req, res, next) { | @@ -39,8 +37,6 @@ exports.vizcard = async function (req, res, next) { | ||
| 39 | moblieNo : req.query.moblieNo | 37 | moblieNo : req.query.moblieNo |
| 40 | }; | 38 | }; |
| 41 | 39 | ||
| 42 | - log.logDetail.addOutput(sacf,sendCmd,"Request",objectData,objectData); | ||
| 43 | - log.logDetail.write(); | ||
| 44 | const result = await connection.requestSoapToSACF(objectData,sendCmd,"POST"); | 40 | const result = await connection.requestSoapToSACF(objectData,sendCmd,"POST"); |
| 45 | log.logDetail.addInput(sacf,getCmd,"Response",result,result.body); | 41 | log.logDetail.addInput(sacf,getCmd,"Response",result,result.body); |
| 46 | // console.log(result.err) | 42 | // console.log(result.err) |
| @@ -56,8 +52,8 @@ exports.vizcard = async function (req, res, next) { | @@ -56,8 +52,8 @@ exports.vizcard = async function (req, res, next) { | ||
| 56 | var response = responseMsg.success(req,getCmd,{resultData:resultSet,rowCount:resultSet.length}); | 52 | var response = responseMsg.success(req,getCmd,{resultData:resultSet,rowCount:resultSet.length}); |
| 57 | 53 | ||
| 58 | stats.reciveSACFResponse(sacf,sendCmd,"Success"); | 54 | stats.reciveSACFResponse(sacf,sendCmd,"Success"); |
| 59 | - log.addSummary(sacf,sendCmd,response); | ||
| 60 | - log.addSummary(sacf,sendCmd,response); | 55 | + log.addSuccessSummary(sacf,sendCmd,response); |
| 56 | + // log.addErrorSummary("ABCD","EFGH",{resultCode : '50000',developerMessage : "error"}); | ||
| 61 | 57 | ||
| 62 | } | 58 | } |
| 63 | 59 | ||
| @@ -66,9 +62,9 @@ exports.vizcard = async function (req, res, next) { | @@ -66,9 +62,9 @@ exports.vizcard = async function (req, res, next) { | ||
| 66 | stats.reciveResponse(sacf,"SPW_"+sendCmd,"Error"); | 62 | stats.reciveResponse(sacf,"SPW_"+sendCmd,"Error"); |
| 67 | } | 63 | } |
| 68 | 64 | ||
| 69 | - log.logDetail.addOutput(sacf,getCmd,"Response",response,response); | 65 | + log.logDetail.addOutput(sacf,getCmd,"Response",resultSet,response); |
| 70 | log.logDetail.write(); | 66 | log.logDetail.write(); |
| 71 | - log.logSummary(); | 67 | + log.logSummary(response); |
| 72 | res.status(200).json(response); | 68 | res.status(200).json(response); |
| 73 | } | 69 | } |
| 74 | }; | 70 | }; |