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 823482 f98b9503a19c122480c3b9c222ec7daa3aa03c12
parent 823481 efa1b7728c9a9a5e542637b28153e2d0db7170bc
child 823483 fd1412038cfe2518892c6176531465f5109b7a7f
push id117694
push userbmo:ystartsev@mozilla.com
push dateFri, 27 Jul 2018 13:09:11 +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,27 @@
 
 /**
  * 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
+      console.log("[DISPATCH] action type:", action.type);
+      /*
+       * 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 JSON.stringify throws.
+      console.warn(e);
       console.log("[DISPATCH]", action);
     }
     next(action);
   };
 }
 
 exports.log = log;