Skip to content

Commit

Permalink
Give some love to "console.log|warn|info" messages missing the JsSIP …
Browse files Browse the repository at this point in the history
…class/module prefix.
  • Loading branch information
ibc committed Feb 5, 2013
1 parent 4be3b23 commit 537d2f2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ JsSIP.C= {
LOG_TRANSACTION: JsSIP.name() +' | '+ 'TRANSACTION' +' | ',
LOG_DIALOG: JsSIP.name() +' | '+ 'DIALOG' +' | ',
LOG_UA: JsSIP.name() +' | '+ 'UA' +' | ',
LOG_URI: JsSIP.name() +' | '+ 'URI' +' | ',
LOG_NAME_ADDR_HEADER: JsSIP.name() +' | '+ 'NAME ADDR HEADER' +' | ',
LOG_INVITE_SESSION: JsSIP.name() +' | '+ 'INVITE SESSION' +' | ',
LOG_CLIENT_INVITE_SESSION: JsSIP.name() +' | '+ 'CLIENT INVITE SESSION' +' | ',
LOG_SERVER_INVITE_SESSION: JsSIP.name() +' | '+ 'SERVER INVITE SESSION' +' | ',
Expand Down
2 changes: 1 addition & 1 deletion src/DigestAuthentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ JsSIP.DigestAuthentication.prototype.authenticate = function(password) {

// nc-value = 8LHEX. Max value = 'FFFFFFFF'
if (this.nc === 4294967296) {
console.log('Maximum "nc" value has been reached. Resetting "nc"');
console.log(JsSIP.C.LOG_DIGEST_AUTHENTICATION + 'Maximum "nc" value has been reached. Resetting "nc"');
this.nc = 1;
}

Expand Down
6 changes: 3 additions & 3 deletions src/MediaSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ JsSIP.MediaSession.prototype = {
};

this.peerConnection.onaddstream = function(mediaStreamEvent) {
console.warn('stream added');
console.warn(JsSIP.C.LOG_MEDIA_SESSION +'stream added');

if (session.remoteView && this.remoteStreams.length > 0) {
session.remoteView.src = webkitURL.createObjectURL(mediaStreamEvent.stream);
Expand All @@ -160,8 +160,8 @@ JsSIP.MediaSession.prototype = {
};

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

Expand Down
2 changes: 1 addition & 1 deletion src/NameAddrHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ JsSIP.NameAddrHeader = function(uri, display_name, parameters) {

// Checks
if(!uri || !uri instanceof JsSIP.URI) {
console.warn('Missing or invalid "uri" in NameAddrHeader');
console.warn(JsSIP.C.LOG_NAME_ADDR_HEADER + 'Missing or invalid "uri" in NameAddrHeader');
throw new JsSIP.Exceptions.InvalidValueError('uri', uri);
}

Expand Down
8 changes: 4 additions & 4 deletions src/UA.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,15 +651,15 @@ JsSIP.UA.prototype.loadConfig = function(configuration) {
// Check Mandatory parameters
for(parameter in JsSIP.UA.configuration_check.mandatory) {
if(!configuration.hasOwnProperty(parameter)) {
console.error('Missing config parameter: ' + parameter);
console.error(JsSIP.C.LOG_UA + 'Missing config parameter: ' + parameter);
throw new JsSIP.Exceptions.ConfigurationError(parameter);
} else {
value = configuration[parameter];
checked_value = JsSIP.UA.configuration_check.mandatory[parameter](value);
if (checked_value !== undefined) {
settings[parameter] = checked_value;
} else {
console.error('Bad configuration parameter ' + parameter + ' with value ' + window.JSON.stringify(value));
console.error(JsSIP.C.LOG_UA + 'Bad configuration parameter ' + parameter + ' with value ' + window.JSON.stringify(value));
throw new JsSIP.Exceptions.ConfigurationError(parameter, value);
}
}
Expand All @@ -680,7 +680,7 @@ JsSIP.UA.prototype.loadConfig = function(configuration) {
if (checked_value !== undefined) {
settings[parameter] = checked_value;
} else {
console.error('Bad configuration parameter ' + parameter + ' with value ' + window.JSON.stringify(value));
console.error(JsSIP.C.LOG_UA + 'Bad configuration parameter ' + parameter + ' with value ' + window.JSON.stringify(value));
throw new JsSIP.Exceptions.ConfigurationError(parameter, value);
}
}
Expand All @@ -690,7 +690,7 @@ JsSIP.UA.prototype.loadConfig = function(configuration) {

// Connection recovery intervals
if(settings.connection_recovery_max_interval < settings.connection_recovery_min_interval) {
console.error('"connection_recovery_max_interval" value is lower than "connection_recovery_min_interval"');
console.error(JsSIP.C.LOG_UA + '"connection_recovery_max_interval" value is lower than "connection_recovery_min_interval"');
throw new JsSIP.Exceptions.ConfigurationError('connection_recovery_max_interval', settings.connection_recovery_max_interval);
}

Expand Down
4 changes: 2 additions & 2 deletions src/URI.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ JsSIP.URI = function(scheme, user, host, port, parameters, headers) {

// Checks
if(!host) {
console.warn('Missing "host" in URI');
console.warn(JsSIP.C.LOG_URI + 'Missing "host" in URI');
throw new JsSIP.Exceptions.InvalidValueError('host', host);
}

Expand Down Expand Up @@ -134,7 +134,7 @@ JsSIP.URI.prototype = {
uri = '';

if(!this.host) {
console.warn(JsSIP.C.LOG_UA +'No domain specified');
console.warn(JsSIP.C.LOG_URI +'No domain specified');
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ JsSIP.Utils= {
}

if (uri.indexOf('@') === -1) {
console.log('Invalid uri. Missing uri domain.');
console.log(JsSIP.C.LOG_UTILS + 'Invalid URI. Missing URI domain.');
return;
}

Expand Down Expand Up @@ -72,12 +72,12 @@ JsSIP.Utils= {
uri = JsSIP.grammar.parse(target, 'lazy_uri');

if (uri === -1) {
console.log('Invalid target: '+ target);
console.log(JsSIP.C.LOG_UTILS + 'Invalid target: '+ target);
return;
}

if (!uri.host && !domain) {
console.log('No domain specified in target nor as function parameter');
console.log(JsSIP.C.LOG_UTILS + 'No domain specified in target nor as function parameter');
return;
}

Expand Down

1 comment on commit 537d2f2

@ibc
Copy link
Member Author

@ibc ibc commented on 537d2f2 Feb 5, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: still there are some console.warn(e) (being e an exception). Should we also apply the JsSIP class/prefix module in those cases? this is:

console.warn(JsSIP.C.LOG_XXXX + e)

Please sign in to comment.