Remove the  option for the logger as it's too expensive. Also reduce the duration's decimal digits
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// @flow

import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { createLogger } from 'redux-logger';
import reducers from './reducers';
import type { Store } from './types/store';

/**
 * Isolate the store creation into a function, so that it can be used outside of the
 * app's execution context, e.g. for testing.
 * @return {object} Redux store.
 */
export default function initializeStore(): Store {
  const middlewares = [thunk];

  if (process.env.NODE_ENV === 'development') {
    middlewares.push(
      createLogger({
        collapsed: true,
        titleFormatter: (action, time, duration) =>
          `[action]    ${action.type} (in ${duration.toFixed(2)} ms)`,
        logErrors: false,
        duration: true,
      })
    );
  }

  const store = createStore(reducers, applyMiddleware(...middlewares));

  return store;
}

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// @flow

import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { createLogger } from 'redux-logger';
import reducers from './reducers';
import type { Store } from './types/store';

/**
 * Isolate the store creation into a function, so that it can be used outside of the
 * app's execution context, e.g. for testing.
 * @return {object} Redux store.
 */
export default function initializeStore(): Store {
  const middlewares = [thunk];

  if (process.env.NODE_ENV === 'development') {
    middlewares.push(
      createLogger({
        collapsed: true,
        titleFormatter: (action, time, duration) =>
          `[action]    ${action.type} (in ${duration} ms)`,
        logErrors: false,
        diff: true,
        duration: true,
      })
    );
  }

  const store = createStore(reducers, applyMiddleware(...middlewares));

  return store;
}
