stats.js
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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;