quieter stdout and stderr logs

This commit is contained in:
ansuz 2016-09-30 15:51:23 +02:00
parent bc73fa2074
commit 4b238de84c
4 changed files with 13 additions and 30 deletions

View File

@ -1,8 +1,6 @@
;(function () { 'use strict';
const Crypto = require('crypto');
const Nacl = require('tweetnacl');
const LogStore = require('./storage/LogStore');
const LAG_MAX_BEFORE_DISCONNECT = 30000;
const LAG_MAX_BEFORE_PING = 15000;
@ -11,7 +9,6 @@ const HISTORY_KEEPER_ID = Crypto.randomBytes(8).toString('hex');
const USE_HISTORY_KEEPER = true;
const USE_FILE_BACKUP_STORAGE = true;
let dropUser;
let historyKeeperKeys = {};
@ -79,10 +76,15 @@ dropUser = function (ctx, user) {
let chan = ctx.channels[chanName];
let idx = chan.indexOf(user);
if (idx < 0) { return; }
console.log("Removing ["+user.id+"] from channel ["+chanName+"]");
if (ctx.verbose) {
console.log("Removing ["+user.id+"] from channel ["+chanName+"]");
}
chan.splice(idx, 1);
if (chan.length === 0) {
console.log("Removing empty channel ["+chanName+"]");
if (ctx.verbose) {
console.log("Removing empty channel ["+chanName+"]");
}
delete ctx.channels[chanName];
delete historyKeeperKeys[chanName];
@ -94,7 +96,9 @@ dropUser = function (ctx, user) {
ctx.store.removeChannel(chanName, function (err) {
if (err) { console.error("[removeChannelErr]: %s", err); }
else {
console.log("Deleted channel [%s] history from database...", chanName);
if (ctx.verbose) {
console.log("Deleted channel [%s] history from database...", chanName);
}
}
});
}, ctx.config.channelRemovalTimeout);
@ -253,7 +257,7 @@ let run = module.exports.run = function (storage, socketServer, config) {
users: {},
channels: {},
timeouts: {},
store: (USE_FILE_BACKUP_STORAGE) ? LogStore.create('messages.log', storage) : storage,
store: storage,
config: config
};
setInterval(function () {

View File

@ -66,7 +66,7 @@ app.get('/api/config', function(req, res){
var httpServer = httpsOpts ? Https.createServer(httpsOpts, app) : Http.createServer(app);
httpServer.listen(config.httpPort,config.httpAddress,function(){
console.log('listening on %s',config.httpPort);
console.log('[%s] listening on port %s', new Date().toISOString(), config.httpPort);
});
var wsConfig = { server: httpServer };
@ -76,7 +76,6 @@ if (config.websocketPort !== config.httpPort) {
}
var wsSrv = new WebSocketServer(wsConfig);
Storage.create(config, function (store) {
console.log('DB connected');
NetfluxSrv.run(store, wsSrv, config);
WebRTCSrv.run(wsSrv);
});

View File

@ -1,19 +0,0 @@
var Fs = require("fs");
var message = function(file, msg) {
file.write(msg+"\n");
};
var create = module.exports.create = function(filePath, backingStore) {
var file = Fs.createWriteStream(filePath, {flags: 'a+'});
var originalMessageFunction = backingStore.message;
backingStore.message = function(channel, msg, callback) {
message(file, msg);
originalMessageFunction(channel, msg, callback);
};
return backingStore;
};

View File

@ -171,7 +171,6 @@ module.exports.create = function (conf, cb) {
root: conf.filePath || './datastore',
channels: { },
};
console.log('storing data in ' + env.root);
Fs.mkdir(env.root, function (err) {
if (err && err.code !== 'EEXIST') {
// TODO: somehow return a nice error