From 15cac393c2512e607173d033a614cd8800322e40 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Sat, 17 Oct 2015 17:49:31 +0000 Subject: [PATCH] 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 --- resources/src/mediawiki/mediawiki.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) 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 -- 2.20.1