make logging configurable
parent
b09b73fcc6
commit
a5ae027043
|
@ -8,6 +8,8 @@ const HISTORY_KEEPER_ID = Crypto.randomBytes(8).toString('hex');
|
||||||
|
|
||||||
const USE_HISTORY_KEEPER = true;
|
const USE_HISTORY_KEEPER = true;
|
||||||
const USE_FILE_BACKUP_STORAGE = true;
|
const USE_FILE_BACKUP_STORAGE = true;
|
||||||
|
const LOG_MESSAGES = false;
|
||||||
|
|
||||||
|
|
||||||
let dropUser;
|
let dropUser;
|
||||||
|
|
||||||
|
@ -15,7 +17,7 @@ const now = function () { return (new Date()).getTime(); };
|
||||||
|
|
||||||
const sendMsg = function (ctx, user, msg) {
|
const sendMsg = function (ctx, user, msg) {
|
||||||
try {
|
try {
|
||||||
console.log('<' + JSON.stringify(msg));
|
if (LOG_MESSAGES) { console.log('<' + JSON.stringify(msg)); }
|
||||||
user.socket.send(JSON.stringify(msg));
|
user.socket.send(JSON.stringify(msg));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e.stack);
|
console.log(e.stack);
|
||||||
|
@ -181,7 +183,7 @@ let run = module.exports.run = function (storage, socketServer) {
|
||||||
ctx.users[user.id] = user;
|
ctx.users[user.id] = user;
|
||||||
sendMsg(ctx, user, [0, '', 'IDENT', user.id]);
|
sendMsg(ctx, user, [0, '', 'IDENT', user.id]);
|
||||||
socket.on('message', function(message) {
|
socket.on('message', function(message) {
|
||||||
console.log('>'+message);
|
if (LOG_MESSAGES) { console.log('>'+message); }
|
||||||
try {
|
try {
|
||||||
handleMessage(ctx, user, message);
|
handleMessage(ctx, user, message);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in New Issue