logging: Add deprecation warning for updateSettings
and also use the Strophe.LogLevel levels for logging in general.
This commit is contained in:
parent
f81a94baf1
commit
5ab1693136
@ -775,7 +775,8 @@
|
|||||||
_converse.chatboxes.onMessage(msg);
|
_converse.chatboxes.onMessage(msg);
|
||||||
|
|
||||||
expect(_converse.log).toHaveBeenCalledWith(
|
expect(_converse.log).toHaveBeenCalledWith(
|
||||||
"onMessage: Ignoring incoming message intended for a different resource: dummy@localhost/some-other-resource", "info");
|
"onMessage: Ignoring incoming message intended for a different resource: dummy@localhost/some-other-resource",
|
||||||
|
Strophe.LogLevel.INFO);
|
||||||
expect(_converse.chatboxes.getChatBox).not.toHaveBeenCalled();
|
expect(_converse.chatboxes.getChatBox).not.toHaveBeenCalled();
|
||||||
_converse.filter_by_resource = false;
|
_converse.filter_by_resource = false;
|
||||||
|
|
||||||
@ -819,7 +820,7 @@
|
|||||||
_converse.chatboxes.onMessage(msg);
|
_converse.chatboxes.onMessage(msg);
|
||||||
expect(_converse.log.calledWith(
|
expect(_converse.log.calledWith(
|
||||||
"onMessage: Ignoring incoming headline message sent with type 'chat' from JID: localhost",
|
"onMessage: Ignoring incoming headline message sent with type 'chat' from JID: localhost",
|
||||||
"info"
|
Strophe.LogLevel.INFO
|
||||||
)).toBeTruthy();
|
)).toBeTruthy();
|
||||||
expect(utils.isHeadlineMessage.called).toBeTruthy();
|
expect(utils.isHeadlineMessage.called).toBeTruthy();
|
||||||
expect(utils.isHeadlineMessage.returned(true)).toBeTruthy();
|
expect(utils.isHeadlineMessage.returned(true)).toBeTruthy();
|
||||||
|
@ -289,7 +289,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
onBookmarkError: function (iq) {
|
onBookmarkError: function (iq) {
|
||||||
_converse.log("Error while trying to add bookmark", "error");
|
_converse.log("Error while trying to add bookmark", Strophe.LogLevel.ERROR);
|
||||||
_converse.log(iq);
|
_converse.log(iq);
|
||||||
// We remove all locally cached bookmarks and fetch them
|
// We remove all locally cached bookmarks and fetch them
|
||||||
// again from the server.
|
// again from the server.
|
||||||
@ -345,7 +345,7 @@
|
|||||||
|
|
||||||
onBookmarksReceivedError: function (deferred, iq) {
|
onBookmarksReceivedError: function (deferred, iq) {
|
||||||
window.sessionStorage.setItem(this.cached_flag, true);
|
window.sessionStorage.setItem(this.cached_flag, true);
|
||||||
_converse.log('Error while fetching bookmarks');
|
_converse.log('Error while fetching bookmarks', Strophe.LogLevel.ERROR);
|
||||||
_converse.log(iq);
|
_converse.log(iq);
|
||||||
if (!_.isNil(deferred)) {
|
if (!_.isNil(deferred)) {
|
||||||
return deferred.reject();
|
return deferred.reject();
|
||||||
|
@ -705,7 +705,7 @@
|
|||||||
try {
|
try {
|
||||||
this.model.destroy();
|
this.model.destroy();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_converse.log(e);
|
_converse.log(e, Strophe.LogLevel.ERROR);
|
||||||
}
|
}
|
||||||
this.remove();
|
this.remove();
|
||||||
_converse.emit('chatBoxClosed', this);
|
_converse.emit('chatBoxClosed', this);
|
||||||
|
@ -144,16 +144,21 @@
|
|||||||
} else {
|
} else {
|
||||||
logger = console;
|
logger = console;
|
||||||
}
|
}
|
||||||
if (_converse.debug) {
|
if (level === Strophe.LogLevel.ERROR) {
|
||||||
if (level === 'error') {
|
|
||||||
logger.log('ERROR: '+txt);
|
logger.log('ERROR: '+txt);
|
||||||
} else {
|
} else if (level === Strophe.LogLevel.WARN) {
|
||||||
logger.log(txt);
|
logger.log('WARNING: '+txt);
|
||||||
|
} else if (level === Strophe.LogLevel.FATAL) {
|
||||||
|
logger.log('FATAL: '+txt);
|
||||||
|
} else if (_converse.debug) {
|
||||||
|
if (level === Strophe.LogLevel.DEBUG) {
|
||||||
|
logger.log('DEBUG: '+txt);
|
||||||
|
} else if (level === Strophe.LogLevel.INFO) {
|
||||||
|
logger.log('INFO: '+txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
_converse.initialize = function (settings, callback) {
|
_converse.initialize = function (settings, callback) {
|
||||||
"use strict";
|
"use strict";
|
||||||
settings = !_.isUndefined(settings) ? settings : {};
|
settings = !_.isUndefined(settings) ? settings : {};
|
||||||
@ -184,7 +189,7 @@
|
|||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
Strophe.log = function (level, msg) { _converse.log(level+' '+msg, level); };
|
Strophe.log = function (level, msg) { _converse.log(level+' '+msg, level); };
|
||||||
Strophe.error = function (msg) { _converse.log(msg, 'error'); };
|
Strophe.error = function (msg) { _converse.log(msg, Strophe.LogLevel.ERROR); };
|
||||||
|
|
||||||
// Add Strophe Namespaces
|
// Add Strophe Namespaces
|
||||||
Strophe.addNamespace('CARBONS', 'urn:xmpp:carbons:2');
|
Strophe.addNamespace('CARBONS', 'urn:xmpp:carbons:2');
|
||||||
@ -657,7 +662,9 @@
|
|||||||
.c('enable', {xmlns: Strophe.NS.CARBONS});
|
.c('enable', {xmlns: Strophe.NS.CARBONS});
|
||||||
this.connection.addHandler(function (iq) {
|
this.connection.addHandler(function (iq) {
|
||||||
if (iq.querySelectorAll('error').length > 0) {
|
if (iq.querySelectorAll('error').length > 0) {
|
||||||
_converse.log('ERROR: An error occured while trying to enable message carbons.');
|
_converse.log(
|
||||||
|
'An error occured while trying to enable message carbons.',
|
||||||
|
Strophe.LogLevel.ERROR);
|
||||||
} else {
|
} else {
|
||||||
this.session.save({carbons_enabled: true});
|
this.session.save({carbons_enabled: true});
|
||||||
_converse.log('Message carbons have been enabled.');
|
_converse.log('Message carbons have been enabled.');
|
||||||
@ -1133,7 +1140,7 @@
|
|||||||
}.bind(this),
|
}.bind(this),
|
||||||
function (err) {
|
function (err) {
|
||||||
alert(__("Sorry, there was an error while trying to add "+name+" as a contact."));
|
alert(__("Sorry, there was an error while trying to add "+name+" as a contact."));
|
||||||
_converse.log(err);
|
_converse.log(err, Strophe.LogLevel.ERROR);
|
||||||
deferred.resolve(err);
|
deferred.resolve(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -1583,7 +1590,7 @@
|
|||||||
if (_converse.filter_by_resource && (to_resource && to_resource !== _converse.resource)) {
|
if (_converse.filter_by_resource && (to_resource && to_resource !== _converse.resource)) {
|
||||||
_converse.log(
|
_converse.log(
|
||||||
'onMessage: Ignoring incoming message intended for a different resource: '+to_jid,
|
'onMessage: Ignoring incoming message intended for a different resource: '+to_jid,
|
||||||
'info'
|
Strophe.LogLevel.INFO
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
} else if (utils.isHeadlineMessage(message)) {
|
} else if (utils.isHeadlineMessage(message)) {
|
||||||
@ -1592,7 +1599,7 @@
|
|||||||
// wrong type ('chat'), so we need to filter them out here.
|
// wrong type ('chat'), so we need to filter them out here.
|
||||||
_converse.log(
|
_converse.log(
|
||||||
"onMessage: Ignoring incoming headline message sent with type 'chat' from JID: "+from_jid,
|
"onMessage: Ignoring incoming headline message sent with type 'chat' from JID: "+from_jid,
|
||||||
'info'
|
Strophe.LogLevel.INFO
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1658,7 +1665,8 @@
|
|||||||
};
|
};
|
||||||
} else if (!_converse.allow_non_roster_messaging) {
|
} else if (!_converse.allow_non_roster_messaging) {
|
||||||
_converse.log('Could not get roster item for JID '+bare_jid+
|
_converse.log('Could not get roster item for JID '+bare_jid+
|
||||||
' and allow_non_roster_messaging is set to false', 'error');
|
' and allow_non_roster_messaging is set to false',
|
||||||
|
Strophe.LogLevel.ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return this.create(_.assignIn({
|
return this.create(_.assignIn({
|
||||||
@ -2166,7 +2174,15 @@
|
|||||||
_converse.whitelisted_plugins);
|
_converse.whitelisted_plugins);
|
||||||
|
|
||||||
_converse.pluggable.initializePlugins({
|
_converse.pluggable.initializePlugins({
|
||||||
'updateSettings': _converse.api.settings.update,
|
'updateSettings': function () {
|
||||||
|
_converse.log(
|
||||||
|
"(DEPRECATION) "+
|
||||||
|
"The `updateSettings` method has been deprecated. "+
|
||||||
|
"Please use `_converse.api.settings.update` instead.",
|
||||||
|
Strophe.LogLevel.WARN
|
||||||
|
)
|
||||||
|
_converse.api.settings.update.apply(_converse, arguments);
|
||||||
|
},
|
||||||
'_converse': _converse
|
'_converse': _converse
|
||||||
}, whitelist, _converse.blacklisted_plugins);
|
}, whitelist, _converse.blacklisted_plugins);
|
||||||
_converse.emit('pluginsInitialized');
|
_converse.emit('pluginsInitialized');
|
||||||
@ -2298,7 +2314,7 @@
|
|||||||
'open': function (jids, attrs) {
|
'open': function (jids, attrs) {
|
||||||
var chatbox;
|
var chatbox;
|
||||||
if (_.isUndefined(jids)) {
|
if (_.isUndefined(jids)) {
|
||||||
_converse.log("chats.open: You need to provide at least one JID", "error");
|
_converse.log("chats.open: You need to provide at least one JID", Strophe.LogLevel.ERROR);
|
||||||
return null;
|
return null;
|
||||||
} else if (_.isString(jids)) {
|
} else if (_.isString(jids)) {
|
||||||
chatbox = _converse.getViewForChatBox(
|
chatbox = _converse.getViewForChatBox(
|
||||||
|
@ -90,7 +90,8 @@
|
|||||||
if (!_converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
if (!_converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
||||||
_converse.log(
|
_converse.log(
|
||||||
"Attempted to fetch archived messages but this "+
|
"Attempted to fetch archived messages but this "+
|
||||||
"user's server doesn't support XEP-0313");
|
"user's server doesn't support XEP-0313",
|
||||||
|
Strophe.LogLevel.WARN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.disable_mam) {
|
if (this.disable_mam) {
|
||||||
@ -107,7 +108,7 @@
|
|||||||
this.clearSpinner();
|
this.clearSpinner();
|
||||||
_converse.log(
|
_converse.log(
|
||||||
"Error or timeout while trying to fetch "+
|
"Error or timeout while trying to fetch "+
|
||||||
"archived messages", "error");
|
"archived messages", Strophe.LogLevel.ERROR);
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -171,7 +172,8 @@
|
|||||||
if (!_converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
if (!_converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
||||||
_converse.log(
|
_converse.log(
|
||||||
"Attempted to fetch archived messages but this "+
|
"Attempted to fetch archived messages but this "+
|
||||||
"user's server doesn't support XEP-0313");
|
"user's server doesn't support XEP-0313",
|
||||||
|
Strophe.LogLevel.WARN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.model.get('mam_enabled')) {
|
if (!this.model.get('mam_enabled')) {
|
||||||
@ -191,7 +193,7 @@
|
|||||||
that.clearSpinner();
|
that.clearSpinner();
|
||||||
_converse.log(
|
_converse.log(
|
||||||
"Error while trying to fetch archived messages",
|
"Error while trying to fetch archived messages",
|
||||||
"error");
|
Strophe.LogLevel.WARN);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -308,9 +310,13 @@
|
|||||||
|
|
||||||
_converse.onMAMError = function (iq) {
|
_converse.onMAMError = function (iq) {
|
||||||
if ($(iq).find('feature-not-implemented').length) {
|
if ($(iq).find('feature-not-implemented').length) {
|
||||||
_converse.log("Message Archive Management (XEP-0313) not supported by this browser");
|
_converse.log(
|
||||||
|
"Message Archive Management (XEP-0313) not supported by this server",
|
||||||
|
Strophe.LogLevel.WARN);
|
||||||
} else {
|
} else {
|
||||||
_converse.log("An error occured while trying to set archiving preferences.");
|
_converse.log(
|
||||||
|
"An error occured while trying to set archiving preferences.",
|
||||||
|
Strophe.LogLevel.ERROR);
|
||||||
_converse.log(iq);
|
_converse.log(iq);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -2689,7 +2689,9 @@
|
|||||||
} else if (_.isObject(room)) {
|
} else if (_.isObject(room)) {
|
||||||
_converse.api.rooms.open(room.jid, room.nick);
|
_converse.api.rooms.open(room.jid, room.nick);
|
||||||
} else {
|
} else {
|
||||||
_converse.log('Invalid room criteria specified for "auto_join_rooms"', 'error');
|
_converse.log(
|
||||||
|
'Invalid room criteria specified for "auto_join_rooms"',
|
||||||
|
Strophe.LogLevel.ERROR);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -148,7 +148,7 @@
|
|||||||
if (_.isUndefined(_converse.roster)) {
|
if (_.isUndefined(_converse.roster)) {
|
||||||
_converse.log(
|
_converse.log(
|
||||||
"Could not send notification, because roster is undefined",
|
"Could not send notification, because roster is undefined",
|
||||||
"error");
|
Strophe.LogLevel.ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
roster_item = _converse.roster.get(from_jid);
|
roster_item = _converse.roster.get(from_jid);
|
||||||
|
@ -351,7 +351,7 @@
|
|||||||
} else {
|
} else {
|
||||||
this.showHelpMessages(['Encryption error occured: '+msg], 'error');
|
this.showHelpMessages(['Encryption error occured: '+msg], 'error');
|
||||||
}
|
}
|
||||||
_converse.log("OTR ERROR:"+msg);
|
_converse.log("OTR ERROR:"+msg, Strophe.LogLevel.ERROR);
|
||||||
},
|
},
|
||||||
|
|
||||||
startOTRFromToolbar: function (ev) {
|
startOTRFromToolbar: function (ev) {
|
||||||
|
@ -304,7 +304,10 @@
|
|||||||
Strophe.Status.CONFLICT
|
Strophe.Status.CONFLICT
|
||||||
], status)) {
|
], status)) {
|
||||||
|
|
||||||
_converse.log('Problem during registration: Strophe.Status is: '+status);
|
_converse.log(
|
||||||
|
'Problem during registration: Strophe.Status is: '+status,
|
||||||
|
Strophe.LogLevel.ERROR
|
||||||
|
);
|
||||||
this.cancelRegistration();
|
this.cancelRegistration();
|
||||||
if (error) {
|
if (error) {
|
||||||
this.giveFeedback(error, 'error');
|
this.giveFeedback(error, 'error');
|
||||||
@ -534,7 +537,7 @@
|
|||||||
this.fields[_var.toLowerCase()] = $(field).children('value').text();
|
this.fields[_var.toLowerCase()] = $(field).children('value').text();
|
||||||
} else {
|
} else {
|
||||||
// TODO: other option seems to be type="fixed"
|
// TODO: other option seems to be type="fixed"
|
||||||
_converse.log("WARNING: Found field we couldn't parse");
|
_converse.log("Found field we couldn't parse", Strophe.LogLevel.WARN);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
this.form_type = 'xform';
|
this.form_type = 'xform';
|
||||||
@ -554,7 +557,7 @@
|
|||||||
query = query[0];
|
query = query[0];
|
||||||
}
|
}
|
||||||
if (stanza.getAttribute("type") === "error") {
|
if (stanza.getAttribute("type") === "error") {
|
||||||
_converse.log("Registration failed.");
|
_converse.log("Registration failed.", Strophe.LogLevel.ERROR);
|
||||||
error = stanza.getElementsByTagName("error");
|
error = stanza.getElementsByTagName("error");
|
||||||
if (error.length !== 1) {
|
if (error.length !== 1) {
|
||||||
_converse.connection._changeConnectStatus(Strophe.Status.REGIFAIL, "unknown");
|
_converse.connection._changeConnectStatus(Strophe.Status.REGIFAIL, "unknown");
|
||||||
|
@ -671,7 +671,7 @@
|
|||||||
}.bind(this),
|
}.bind(this),
|
||||||
function (err) {
|
function (err) {
|
||||||
alert(__("Sorry, there was an error while trying to remove "+name+" as a contact."));
|
alert(__("Sorry, there was an error while trying to remove "+name+" as a contact."));
|
||||||
_converse.log(err);
|
_converse.log(err, Strophe.LogLevel.ERROR);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,10 @@
|
|||||||
bare_jid,
|
bare_jid,
|
||||||
_.partial(_converse.createRequestingContactFromVCard, presence),
|
_.partial(_converse.createRequestingContactFromVCard, presence),
|
||||||
function (iq, jid) {
|
function (iq, jid) {
|
||||||
_converse.log("Error while retrieving vcard for "+jid);
|
_converse.log(
|
||||||
|
"Error while retrieving vcard for "+jid,
|
||||||
|
Strophe.LogLevel.ERROR
|
||||||
|
);
|
||||||
_converse.createRequestingContactFromVCard(presence, iq, jid);
|
_converse.createRequestingContactFromVCard(presence, iq, jid);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -148,7 +151,8 @@
|
|||||||
},
|
},
|
||||||
function () {
|
function () {
|
||||||
_converse.log(
|
_converse.log(
|
||||||
"updateVCardForChatBox: Error occured while fetching vcard"
|
"updateVCardForChatBox: Error occured while fetching vcard",
|
||||||
|
Strophe.LogLevel.ERROR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user