Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1522 from thaliproject/master_coordinated-client-…
Browse files Browse the repository at this point in the history
…logging

Improve CoordinatedClient logging
  • Loading branch information
chapko committed Nov 16, 2016
2 parents 7dd237b + 9d40c45 commit 1b622bc
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions test/www/jxcore/lib/CoordinatedClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ function CoordinatedClient(tests, uuid, platform, version, hasRequiredHardware,

this._state = CoordinatedClient.states.created;

var serverUrl = 'http://' + serverAddress + ':' + DEFAULT_SERVER_PORT + '/';
logger.info('Connecting to coordination server on ' + serverUrl);
this._io = SocketIOClient(
'http://' + serverAddress + ':' + DEFAULT_SERVER_PORT + '/',
serverUrl,
{
reconnection: true,
reconnectionAttempts: 15,
Expand Down Expand Up @@ -96,9 +98,9 @@ CoordinatedClient.prototype._bind = function () {
this._io
.on ('connect', this._connect.bind(this))
.on ('connect_timeout', logger.debug.bind(logger))
.on ('connect_error', logger.error.bind(logger))
.on ('connect_error', this._connectionError.bind(this))
.on ('reconnect', this._reconnect.bind(this))
.on ('reconnect_error', logger.error.bind(logger))
.on ('reconnect_error', this._connectionError.bind(this))
.on ('reconnect_failed', this._error.bind(this))
.once('schedule', this._schedule.bind(this))
.on ('discard', this._discard.bind(this))
Expand Down Expand Up @@ -155,9 +157,10 @@ CoordinatedClient.prototype._schedule = function (data) {
return Promise.all(promises);
})
.catch(function (error) {
var stack = error ? error.stack : null;
logger.error(
'unexpected error: \'%s\', stack: \'%s\'',
error.toString(), error.stack
String(error), stack
);
self._failed(error);
});
Expand Down Expand Up @@ -218,9 +221,20 @@ CoordinatedClient.prototype._disconnect = function () {
};

CoordinatedClient.prototype._error = function (error) {
var stack = error ? error.stack : null;
logger.error(
'unexpected error: \'%s\', stack: \'%s\'',
error.toString(), error.stack
String(error), stack
);
this._failed(error);
};

CoordinatedClient.prototype._connectionError = function (error) {
var stack = error ? error.stack : null;
var description = error ? error.description : null;
logger.error(
'connection error: \'%s\', description: \'%s\', stack: \'%s\'',
String(error), description, stack
);
this._failed(error);
};
Expand Down Expand Up @@ -279,9 +293,10 @@ CoordinatedClient.prototype._emit = function (event, data, externalOptions) {
emit();
})
.catch(function (error) {
var stack = error ? error.stack : null;
logger.error(
'unexpected error: \'%s\', stack: \'%s\'',
error.toString(), error.stack
String(error), stack
);
return Promise.reject(error);
})
Expand Down

0 comments on commit 1b622bc

Please sign in to comment.