Skip to content

Commit

Permalink
Some more love to logs (avoid consecutive logs, instead join them in …
Browse files Browse the repository at this point in the history
…a single log).
  • Loading branch information
ibc committed Feb 20, 2013
1 parent 1b1ab73 commit 2d2255f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
7 changes: 2 additions & 5 deletions src/MediaSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ JsSIP.MediaSession.prototype = {
if (event.candidate) {
console.log(JsSIP.C.LOG_MEDIA_SESSION + 'ICE candidate received: '+ event.candidate.candidate);
} else {
console.log(JsSIP.C.LOG_MEDIA_SESSION + 'no more ICE candidates');
console.log(JsSIP.C.LOG_MEDIA_SESSION + 'PeerConnection state: '+ this.readyState);
console.log(JsSIP.C.LOG_MEDIA_SESSION + 'ICE state: '+ this.iceState);
console.log(JsSIP.C.LOG_MEDIA_SESSION + 'no more ICE candidates | PeerConnection state: '+ this.readyState + ' | ICE state: '+ this.iceState);
if (!sent) { // Execute onSuccess just once.
sent = true;
onSuccess();
Expand All @@ -158,8 +156,7 @@ JsSIP.MediaSession.prototype = {
};

this.peerConnection.onstatechange = function() {
console.log(JsSIP.C.LOG_MEDIA_SESSION + 'PeerConnection state changed to '+ this.readyState);
console.log(JsSIP.C.LOG_MEDIA_SESSION + 'ICE state: '+ this.iceState);
console.log(JsSIP.C.LOG_MEDIA_SESSION + 'PeerConnection state changed to '+ this.readyState + ' | ICE state: '+ this.iceState);
};
},

Expand Down
9 changes: 3 additions & 6 deletions src/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,16 +445,14 @@ JsSIP.Session.prototype.receiveInitialRequest = function(request) {
};

onMediaFailure = function(e) {
console.warn(JsSIP.C.LOG_INVITE_SESSION +'unable to get user media');
console.warn(e);
console.warn(JsSIP.C.LOG_INVITE_SESSION +'unable to get user media: ' + e);
request.reply(480);
session.failed('local', null, JsSIP.C.causes.USER_DENIED_MEDIA_ACCESS);
};

onSdpFailure = function(e) {
// Bad SDP Offer. peerConnection.setRemoteDescription throws an exception.
console.warn(JsSIP.C.LOG_INVITE_SESSION +'invalid SDP');
console.warn(e);
console.warn(JsSIP.C.LOG_INVITE_SESSION +'invalid SDP: ' + e);
request.reply(488);
session.failed('remote', request, JsSIP.C.causes.BAD_MEDIA_DESCRIPTION);
};
Expand Down Expand Up @@ -1074,8 +1072,7 @@ JsSIP.Session.prototype.sendInitialRequest = function(mediaTypes) {

function onMediaFailure(e) {
if (self.status !== JsSIP.C.SESSION_TERMINATED) {
console.warn(JsSIP.C.LOG_INVITE_SESSION +'unable to get user media');
console.warn(e);
console.warn(JsSIP.C.LOG_INVITE_SESSION +'unable to get user media: ' + e);
self.failed('local', null, JsSIP.C.causes.USER_DENIED_MEDIA_ACCESS);
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/Transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ JsSIP.Transport.prototype = {
try {
this.ws = new WebSocket(this.server.ws_uri, 'sip');
} catch(e) {
console.warn(JsSIP.C.LOG_TRANSPORT +'error connecting to WebSocket ' + this.server.ws_uri);
console.warn(e);
console.warn(JsSIP.C.LOG_TRANSPORT +'error connecting to WebSocket ' + this.server.ws_uri + ': ' + e);
}

this.ws.binaryType = 'arraybuffer';
Expand Down Expand Up @@ -131,7 +130,7 @@ JsSIP.Transport.prototype = {
this.connected = false;
this.lastTransportError.code = e.code;
this.lastTransportError.reason = e.reason;
console.warn(JsSIP.C.LOG_TRANSPORT +'WebSocket disconnected (code: ' + e.code + (e.reason? ', reason: ' + e.reason : '') +')');
console.warn(JsSIP.C.LOG_TRANSPORT +'WebSocket disconnected (code: ' + e.code + (e.reason? '| reason: ' + e.reason : '') +')');

if(e.wasClean === false) {
console.warn(JsSIP.C.LOG_TRANSPORT +'WebSocket abrupt disconnection');
Expand Down Expand Up @@ -237,8 +236,7 @@ JsSIP.Transport.prototype = {
* @param {event} e
*/
onError: function(e) {
console.warn(JsSIP.C.LOG_TRANSPORT +'WebSocket connection error');
console.warn(e);
console.warn(JsSIP.C.LOG_TRANSPORT +'WebSocket connection error: ' + e);
},

/**
Expand Down
9 changes: 4 additions & 5 deletions src/UA.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,11 @@ JsSIP.UA.prototype.onTransportClosed = function(transport) {
JsSIP.UA.prototype.onTransportError = function(transport) {
var server;

console.log(JsSIP.C.LOG_UA +'transport ' + transport.server.ws_uri + ' failed');
console.log(JsSIP.C.LOG_UA +'transport ' + transport.server.ws_uri + ' failed | connection state set to '+ JsSIP.C.WS_SERVER_ERROR);

// Close sessions.
//Mark this transport as 'down' and try the next one
transport.server.status = JsSIP.C.WS_SERVER_ERROR;
console.log(JsSIP.C.LOG_UA +'connection state set to '+ JsSIP.C.WS_SERVER_ERROR);

this.emit('disconnected', this, {
transport: transport,
Expand Down Expand Up @@ -357,7 +356,7 @@ JsSIP.UA.prototype.receiveRequest = function(request) {

// Check that Ruri points to us
if(request.ruri.user !== this.configuration.uri.user && request.ruri.user !== this.contact.uri.user) {
console.log(JsSIP.C.LOG_UA +'Request-URI does not point to us');
console.warn(JsSIP.C.LOG_UA +'Request-URI does not point to us');
if (request.method !== JsSIP.C.ACK) {
request.reply_sl(404);
}
Expand Down Expand Up @@ -423,7 +422,7 @@ JsSIP.UA.prototype.receiveRequest = function(request) {
if(session) {
session.receiveRequest(request);
} else {
console.log(JsSIP.C.LOG_UA +'received CANCEL request for a non existent session');
console.warn(JsSIP.C.LOG_UA +'received CANCEL request for a non existent session');
}
break;
case JsSIP.C.ACK:
Expand All @@ -448,7 +447,7 @@ JsSIP.UA.prototype.receiveRequest = function(request) {
if(session) {
session.receiveRequest(request);
} else {
console.log(JsSIP.C.LOG_UA +'received NOTIFY request for a non existent session');
console.warn(JsSIP.C.LOG_UA +'received NOTIFY request for a non existent session');
request.reply(481, 'Subscription does not exist');
}
}
Expand Down

0 comments on commit 2d2255f

Please sign in to comment.