Skip to content

Commit

Permalink
changed loglevel of web socket server to be lowest
Browse files Browse the repository at this point in the history
  • Loading branch information
rotemmiz committed Mar 14, 2017
1 parent 6b03ef1 commit fc1230a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 6 additions & 6 deletions detox-server/src/DetoxServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DetoxServer {
this.wss = new WebSocketServer({port: port});
this.sessions = {};

log.http(`${now()}:`, `server listening on localhost:${this.wss.options.port}...`);
log.wss(`${now()}:`, `server listening on localhost:${this.wss.options.port}...`);
this._setup();
}

Expand All @@ -25,21 +25,21 @@ class DetoxServer {
if (action.params && action.params.sessionId && action.params.role) {
sessionId = action.params.sessionId;
role = action.params.role;
log.http(`${now()}:`, `role=${role} login (sessionId=${sessionId})`);
log.wss(`${now()}:`, `role=${role} login (sessionId=${sessionId})`);
_.set(this.sessions, [sessionId, role], ws);
}
} else if (sessionId && role) {
log.http(`${now()}:`, `role=${role} action=${action.type} (sessionId=${sessionId})`);
log.wss(`${now()}:`, `role=${role} action=${action.type} (sessionId=${sessionId})`);
this.sendToOtherRole(sessionId, role, action.type, action.params);
}
} catch (error) {
log.http(`Invalid JSON received, cannot parse`);
log.wss(`Invalid JSON received, cannot parse`);
}
});

ws.on('close', () => {
if (sessionId && role) {
log.http(`${now()}:`, `role=${role} disconnect (sessionId=${sessionId})`);
log.wss(`${now()}:`, `role=${role} disconnect (sessionId=${sessionId})`);
_.set(this.sessions, [sessionId, role], undefined);
}
});
Expand All @@ -59,7 +59,7 @@ class DetoxServer {
if (ws) {
this.sendAction(ws, type, params);
} else {
log.http(`${now()}:`, `role=${otherRole} not connected, cannot fw action (sessionId=${sessionId})`);
log.wss(`${now()}:`, `role=${otherRole} not connected, cannot fw action (sessionId=${sessionId})`);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion detox-server/src/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#! /usr/bin/env node
const log = require('npmlog');
const DetoxServer = require('./DetoxServer');

const detoxServer = new DetoxServer(8099);
log.addLevel('wss', 999, {fg: 'blue', bg: 'black'}, 'verb');
log.level = 'wss';

const detoxServer = new DetoxServer(8099);
1 change: 1 addition & 0 deletions detox/src/detox.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const URL = require('url').URL;
const _ = require('lodash');

log.level = argparse.getArgValue('loglevel') || 'info';
log.addLevel('wss', 999, {fg: 'blue', bg: 'black'}, 'verb');
log.heading = 'detox';

class Detox {
Expand Down

0 comments on commit fc1230a

Please sign in to comment.