2016-12-15 21:30:55 +00:00
|
|
|
const util = require('util');
|
|
|
|
const config = require(__dirname+'/config');
|
2016-11-14 15:20:27 +00:00
|
|
|
|
|
|
|
module.exports.log = function() {
|
|
|
|
console.log.apply(null, arguments);
|
2016-12-15 21:30:55 +00:00
|
|
|
};
|
2016-11-14 15:20:27 +00:00
|
|
|
|
|
|
|
module.exports.debugLog = function() {
|
|
|
|
if(!config.server.debug) return;
|
|
|
|
|
|
|
|
console.log.apply(null, arguments);
|
2016-12-15 21:30:55 +00:00
|
|
|
};
|
2016-11-14 15:20:27 +00:00
|
|
|
|
|
|
|
module.exports.errorLog = function(errObj, specify) {
|
|
|
|
if(specify)
|
|
|
|
console.error(specify);
|
|
|
|
|
|
|
|
console.error(errObj);
|
|
|
|
|
|
|
|
if(errObj.stack)
|
|
|
|
console.error(errObj.stack);
|
2016-12-15 21:30:55 +00:00
|
|
|
};
|
2016-11-14 15:20:27 +00:00
|
|
|
|
|
|
|
module.exports.printRuntimeStats = function(runtime_stats, connections) {
|
|
|
|
if(!config.server.printStats) return;
|
|
|
|
|
|
|
|
let date = new Date();
|
|
|
|
let users = 0;
|
|
|
|
let servers = 0;
|
|
|
|
let serversPerUser = 0;
|
|
|
|
|
|
|
|
for(let uid in connections) {
|
|
|
|
let ca = connections[uid];
|
|
|
|
users += 1;
|
|
|
|
for(let snam in ca) {
|
|
|
|
if(!snam) continue;
|
2016-12-15 21:30:55 +00:00
|
|
|
if(snam == 'host') continue;
|
2016-11-14 15:20:27 +00:00
|
|
|
servers += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(users != 0) // Don't divide by zero lmao
|
|
|
|
serversPerUser = servers/users;
|
|
|
|
|
2016-12-21 18:54:22 +00:00
|
|
|
console.log(date+(': Currently connected users: {0}. ' +
|
|
|
|
'IRC server connections: {1}. ' +
|
|
|
|
'Average servers per user: {2}. ' +
|
|
|
|
'Total connections made: {3}. ' +
|
|
|
|
'Uptime: {4}s;').format(users, servers, serversPerUser, runtime_stats.connectionsMade, process.uptime()));
|
2016-12-15 21:30:55 +00:00
|
|
|
};
|