var config = require('./config'); var log = require('./log.js'); var constants = require('./constants.js'); var nodeName = config.get("appName"); var stat = []; //client and Node stat.receiveRequest = function (method,cmd,from){ writeStats(nodeName+" receive "+method+" "+cmd+" request from "+(from?from:"Client")); }; stat.sendResponse = function (method,cmd,to){ writeStats(nodeName+" send "+method+" "+cmd+" response to "+(to?to:"Client")); }; //node and mongo stat.sendQuery = function (cmd,to){ writeStats(nodeName+" send QUERY "+cmd+" request to "+(to?to:"MongoDB")); }; stat.receiveQuery = function (cmd,from){ writeStats(nodeName+" receive QUERY "+cmd+" response from "+(from?from:"MongoDB")); }; //unknow stat.receiveUnknow = function(message){ writeStats(nodeName+" Receive "+message+" "+constants.REQUEST); }; stat.sendUnknow = function(message){ writeStats(nodeName+" Send "+message); }; function writeStats(string) { log.log(string); log.stat(string); } module.exports = stat;