From: Fomafix Date: Sat, 17 Oct 2015 17:49:31 +0000 (+0000) Subject: mediawiki.js: Show line number of caller of mw.log.warn and .error X-Git-Tag: 1.31.0-rc.0~9362 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=15cac393c2512e607173d033a614cd8800322e40;p=lhc%2Fweb%2Fwiklou.git mediawiki.js: Show line number of caller of mw.log.warn and .error Currently the JavaScript console shows the line number from mediawiki.js where the function mw.log.warn is defined. With this change the JavaScript console shows the file and the line number where the function mw.log.warn is called. Inspirited by https://matthewspencer.github.io/console-log/ Change-Id: I2345333fc0158a66ebcb3abf0e94e6e622b3bdc0 --- diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index 12d698b452..568bfd43bc 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -588,7 +588,8 @@ log: ( function () { // Also update the restoration of methods in mediawiki.log.js // when adding or removing methods here. - var log = function () {}; + var log = function () {}, + console = window.console; /** * @class mw.log @@ -601,12 +602,9 @@ * * @param {...string} msg Messages to output to console */ - log.warn = function () { - var console = window.console; - if ( console && console.warn && console.warn.apply ) { - console.warn.apply( console, arguments ); - } - }; + log.warn = console && console.warn && Function.prototype.bind ? + Function.prototype.bind.call( console.warn, console ) : + $.noop; /** * Write a message the console's error channel. @@ -617,12 +615,9 @@ * @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 ); - } - }; + log.error = console && console.error && Function.prototype.bind ? + Function.prototype.bind.call( console.error, console ) : + $.noop; /** * Create a property in a host object that, when accessed, will produce