Bug 1473513 - make log function safer so that tests do not time out; r=ochameau
MozReview-Commit-ID: BIk5pWzxJcx
--- 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;