log.js 488 B

123456789101112131415161718
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. /**
  6. * A middleware that logs all actions coming through the system
  7. * to the console.
  8. */
  9. function log({ dispatch, getState }) {
  10. return next => action => {
  11. console.log("[DISPATCH]", JSON.stringify(action, null, 2));
  12. next(action);
  13. };
  14. }
  15. exports.log = log;