In addition to mw.log.warn, but for the console.error channel.
Change-Id: I7b09a75da6c985a9e0cc73591f49b21972efd393
}
};
+ /**
+ * Write a message the console's error channel.
+ *
+ * Most browsers provide a stacktrace by default if the argument
+ * is a caught Error object.
+ *
+ * @since 1.26
+ * @param {Error|string...} msg Messages to output to console
+ */
+ log.error = function () {
+ var console = window.console;
+ if ( console && console.error && console.error.apply ) {
+ console.error.apply( console, arguments );
+ }
+ };
+
/**
* Create a property in a host object that, when accessed, will produce
* a deprecation warning in the console with backtrace.
// Restore original methods
mw.log.warn = original.warn;
+ mw.log.error = original.error;
mw.log.deprecate = original.deprecate;
}( mediaWiki, jQuery ) );
* </code>
*/
QUnit.newMwEnvironment = ( function () {
- var warn, log, liveConfig, liveMessages,
+ var warn, error, log, liveConfig, liveMessages,
ajaxRequests = [];
liveConfig = mw.config.values;
function suppressWarnings() {
warn = mw.log.warn;
- mw.log.warn = $.noop;
+ error = mw.log.error;
+ mw.log.warn = mw.log.error = $.noop;
}
function restoreWarnings() {
+ // Guard against calls not balanced with suppressWarnings()
if ( warn !== undefined ) {
mw.log.warn = warn;
- warn = undefined;
+ mw.log.error = error;
+ warn = error = undefined;
}
}