jenkins-bot has submitted this change and it was merged.

Change subject: mediawiki.log: Introduce mw.log.error
......................................................................


mediawiki.log: Introduce mw.log.error

In addition to mw.log.warn, but for the console.error channel.

Change-Id: I7b09a75da6c985a9e0cc73591f49b21972efd393
---
M resources/src/mediawiki/mediawiki.js
M resources/src/mediawiki/mediawiki.log.js
M tests/qunit/data/testrunner.js
3 files changed, 23 insertions(+), 3 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/src/mediawiki/mediawiki.js 
b/resources/src/mediawiki/mediawiki.js
index ee57c21..237157c 100644
--- a/resources/src/mediawiki/mediawiki.js
+++ b/resources/src/mediawiki/mediawiki.js
@@ -590,6 +590,22 @@
                        };
 
                        /**
+                        * 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.
                         *
diff --git a/resources/src/mediawiki/mediawiki.log.js 
b/resources/src/mediawiki/mediawiki.log.js
index ad68967..053fb1a 100644
--- a/resources/src/mediawiki/mediawiki.log.js
+++ b/resources/src/mediawiki/mediawiki.log.js
@@ -79,6 +79,7 @@
 
        // Restore original methods
        mw.log.warn = original.warn;
+       mw.log.error = original.error;
        mw.log.deprecate = original.deprecate;
 
 }( mediaWiki, jQuery ) );
diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js
index 3c44b55..3dd2af6 100644
--- a/tests/qunit/data/testrunner.js
+++ b/tests/qunit/data/testrunner.js
@@ -179,7 +179,7 @@
         * </code>
         */
        QUnit.newMwEnvironment = ( function () {
-               var warn, log, liveConfig, liveMessages,
+               var warn, error, log, liveConfig, liveMessages,
                        ajaxRequests = [];
 
                liveConfig = mw.config.values;
@@ -187,13 +187,16 @@
 
                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;
                        }
                }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/205989
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7b09a75da6c985a9e0cc73591f49b21972efd393
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Hashar <has...@free.fr>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to