console.warn is not supported on FF < 52

This commit is contained in:
JC Brand 2017-08-21 11:27:47 +02:00
parent d70746d6ef
commit 016bca74b8
2 changed files with 16 additions and 9 deletions

View File

@ -121,10 +121,10 @@
message = message.stack; message = message.stack;
} }
const logger = _.assignIn({ const logger = _.assignIn({
'debug': _.noop, 'debug': console.log || _.noop,
'error': _.noop, 'error': console.log || _.noop,
'info': _.noop, 'info': console.log || _.noop,
'warn': _.noop, 'warn': console.log || _.noop,
}, console); }, console);
if (level === Strophe.LogLevel.ERROR) { if (level === Strophe.LogLevel.ERROR) {
if (_converse.debug) { if (_converse.debug) {
@ -136,7 +136,7 @@
logger.warn(`WARNING: ${message}`); logger.warn(`WARNING: ${message}`);
} else if (level === Strophe.LogLevel.FATAL) { } else if (level === Strophe.LogLevel.FATAL) {
if (_converse.debug) { if (_converse.debug) {
logger.error(`FATAL: ${message}`); logger.trace(`FATAL: ${message}`);
} else { } else {
logger.error(`FATAL: ${message}`); logger.error(`FATAL: ${message}`);
} }

View File

@ -33,6 +33,13 @@
const URL_REGEX = /\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<>]{2,200}\b/g; const URL_REGEX = /\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<>]{2,200}\b/g;
const logger = _.assignIn({
'debug': console.log || _.noop,
'error': console.log || _.noop,
'info': console.log || _.noop,
'warn': console.log || _.noop,
}, console);
var afterAnimationEnd = function (el, callback) { var afterAnimationEnd = function (el, callback) {
el.classList.remove('visible'); el.classList.remove('visible');
if (_.isFunction(callback)) { if (_.isFunction(callback)) {
@ -198,7 +205,7 @@
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (_.isNil(el)) { if (_.isNil(el)) {
const err = "Undefined or null element passed into slideOut" const err = "Undefined or null element passed into slideOut"
console.warn(err); logger.warn(err);
reject(new Error(err)); reject(new Error(err));
return; return;
} }
@ -242,7 +249,7 @@
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (_.isNil(el)) { if (_.isNil(el)) {
const err = "Undefined or null element passed into slideIn"; const err = "Undefined or null element passed into slideIn";
console.warn(err); logger.warn(err);
return reject(new Error(err)); return reject(new Error(err));
} else if (_.includes(el.classList, 'collapsed')) { } else if (_.includes(el.classList, 'collapsed')) {
return resolve(); return resolve();
@ -280,7 +287,7 @@
u.fadeIn = function (el, callback) { u.fadeIn = function (el, callback) {
if (_.isNil(el)) { if (_.isNil(el)) {
console.warn("Undefined or null element passed into fadeIn"); logger.warn("Undefined or null element passed into fadeIn");
} }
if (window.converse_disable_effects) { // Effects are disabled (for tests) if (window.converse_disable_effects) { // Effects are disabled (for tests)
el.classList.remove('hidden'); el.classList.remove('hidden');
@ -488,7 +495,7 @@
var obj = window.JSON.parse(preferred_locale); var obj = window.JSON.parse(preferred_locale);
return obj.locale_data.converse[""].lang; return obj.locale_data.converse[""].lang;
} catch (e) { } catch (e) {
console.log(e); logger.error(e);
} }
} }
return u.detectLocale(isSupportedByLibrary) || 'en'; return u.detectLocale(isSupportedByLibrary) || 'en';