Bug 1473513 - make log function safer so that tests do not time out; r=ochameau draft
authoryulia <ystartsev@mozilla.com>
Wed, 25 Jul 2018 11:55:03 +0200
changeset 822496 c90a0823d6ef597365e1475d704daaeb8d532e9b
parent 822491 f0091720149f748b4cb6c9ed9fe075ed29b6b88d
child 822497 baf92ab4f16882a312fee3af3a7e2a07306eeb73
push id117393
push userbmo:ystartsev@mozilla.com
push dateWed, 25 Jul 2018 12:52:00 +0000
reviewersochameau
bugs1473513
milestone63.0a1
Bug 1473513 - make log function safer so that tests do not time out; r=ochameau MozReview-Commit-ID: BIk5pWzxJcx
devtools/client/shared/redux/middleware/log.js
--- a/devtools/client/shared/redux/middleware/log.js
+++ b/devtools/client/shared/redux/middleware/log.js
@@ -5,17 +5,28 @@
 
 /**
  * A middleware that logs all actions coming through the system
  * to the console.
  */
 function log({ dispatch, getState }) {
   return next => action => {
     try {
-      console.log("[DISPATCH]", JSON.stringify(action, null, 2));
+      // whitelist of fields, rather than printing the whole object
+      const whitelist = ["type"];
+      console.log("[DISPATCH]", JSON.stringify(action, whitelist, 2));
+      /*
+       * USE WITH CAUTION!! This will output everything from an action object,
+       * and these can be quite large. Printing out large objects will slow
+       * down tests and cause test failures
+       *
+       * console.log("[DISPATCH]", JSON.stringify(action, null, 2));
+       */
     } catch (e) {
+      // this occurs if an object has a cyclical value and is printed out.
+      console.warn(e);
       console.log("[DISPATCH]", action);
     }
     next(action);
   };
 }
 
 exports.log = log;