set log level via the config file, not via a constant
This commit is contained in:
parent
cae750cd75
commit
fe261c34bb
@ -2,13 +2,13 @@
|
|||||||
const Crypto = require('crypto');
|
const Crypto = require('crypto');
|
||||||
const LogStore = require('./storage/LogStore');
|
const LogStore = require('./storage/LogStore');
|
||||||
|
|
||||||
|
|
||||||
const LAG_MAX_BEFORE_DISCONNECT = 30000;
|
const LAG_MAX_BEFORE_DISCONNECT = 30000;
|
||||||
const LAG_MAX_BEFORE_PING = 15000;
|
const LAG_MAX_BEFORE_PING = 15000;
|
||||||
const HISTORY_KEEPER_ID = Crypto.randomBytes(8).toString('hex');
|
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;
|
||||||
@ -17,7 +17,7 @@ const now = function () { return (new Date()).getTime(); };
|
|||||||
|
|
||||||
const sendMsg = function (ctx, user, msg) {
|
const sendMsg = function (ctx, user, msg) {
|
||||||
try {
|
try {
|
||||||
if (LOG_MESSAGES) { console.log('<' + JSON.stringify(msg)); }
|
if (ctx.config.logToStdout) { 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);
|
||||||
@ -153,11 +153,12 @@ const handleMessage = function (ctx, user, msg) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let run = module.exports.run = function (storage, socketServer) {
|
let run = module.exports.run = function (storage, socketServer, config) {
|
||||||
let ctx = {
|
let ctx = {
|
||||||
users: {},
|
users: {},
|
||||||
channels: {},
|
channels: {},
|
||||||
store: (USE_FILE_BACKUP_STORAGE) ? LogStore.create('messages.log', storage) : storage
|
store: (USE_FILE_BACKUP_STORAGE) ? LogStore.create('messages.log', storage) : storage,
|
||||||
|
config: config
|
||||||
};
|
};
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
Object.keys(ctx.users).forEach(function (userId) {
|
Object.keys(ctx.users).forEach(function (userId) {
|
||||||
@ -183,7 +184,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) {
|
||||||
if (LOG_MESSAGES) { console.log('>'+message); }
|
if (ctx.config.logToStdout) { console.log('>'+message); }
|
||||||
try {
|
try {
|
||||||
handleMessage(ctx, user, message);
|
handleMessage(ctx, user, message);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user