redux-logger#createLogger JavaScript Examples

The following examples show how to use redux-logger#createLogger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: store.js    From github-azure-demo with MIT License 6 votes vote down vote up
getMiddleware = () => {
    if (
        process.env.NODE_ENV === "production" ||
        process.env.NODE_ENV === "test"
    ) {
        return applyMiddleware(
            myRouterMiddleware,
            promiseMiddleware,
            localStorageMiddleware
        );
    } else {
        // Enable additional logging in non-production environments.
        return applyMiddleware(
            myRouterMiddleware,
            promiseMiddleware,
            localStorageMiddleware,
            createLogger()
        );
    }
}
Example #2
Source File: store.js    From react-14.01 with MIT License 6 votes vote down vote up
initStore = (preloadedState = {}) => {

    return configureStore({
        reducer: persist,
        middleware: [createLogger(), routerMiddleware(history), chatMiddleware, botMiddleware, UnreadMessageMiddleware, thunk],
        preloadedState,
        devTools: devTools,

    })
}
Example #3
Source File: store.js    From substrate-authn-faucet-frontend with GNU General Public License v3.0 6 votes vote down vote up
configureStore = () => {
  const middlewares = Array.prototype.concat(
    [],
    [thunk, routerMiddleware(history)],
    process.env.NODE_ENV === 'development' ? [createLogger()] : []
  );

  const composeEnhancers =
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
  const enhancer = composeEnhancers(
    applyMiddleware(...middlewares),
    responsiveStoreEnhancer
  );

  store = createStore(resetEnhancer(createReducer(history)), enhancer);
  store.asyncReducers = {};

  return {
    store,
    history
  };
}
Example #4
Source File: configureStore.js    From airtable-api-connection with MIT No Attribution 6 votes vote down vote up
configureStore = (initialState) => {
  const middleware = [];
  // const enhancers = [];

  // THUNK
  middleware.push(thunk);

  // Logging Middleware
  const logger = createLogger({
    level: 'info',
    collapsed: true
  });
  middleware.push(logger);

  const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

  store = createStore(rootReducer, initialState, composeEnhancers(
    applyMiddleware(...middleware)
  ));

}
Example #5
Source File: createStore.js    From volt-mx-tutorials with Apache License 2.0 6 votes vote down vote up
function createMiddlewares() {
  let middlewares = [thunk];
  if ((process.env.NODE_ENV === "development" || process.env.NODE_ENV === "testing") && typeof window !== "undefined") {
    middlewares.push(
      createLogger({
        level: "info",
        collapsed: true
      })
    );
  }

  return middlewares;
}
Example #6
Source File: configureStore.dev.js    From Learning-Redux with MIT License 6 votes vote down vote up
configureStore = (preloadedState) => {
  const store = createStore(
    rootReducer,
    preloadedState,
    compose(applyMiddleware(thunk, api, createLogger()), DevTools.instrument())
  )

  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
    module.hot.accept('../reducers', () => {
      store.replaceReducer(rootReducer)
    })
  }

  return store
}
Example #7
Source File: configureStore.js    From frontend-app-authn with GNU Affero General Public License v3.0 6 votes vote down vote up
function composeMiddleware() {
  if (getConfig().ENVIRONMENT === 'development') {
    const loggerMiddleware = createLogger({
      collapsed: true,
    });
    return composeWithDevTools(applyMiddleware(thunkMiddleware, sagaMiddleware, loggerMiddleware));
  }

  return compose(applyMiddleware(thunkMiddleware, sagaMiddleware));
}
Example #8
Source File: config.js    From admin-web with GNU Affero General Public License v3.0 6 votes vote down vote up
// Fetch config.js on server and merge with default config
fetch('//' + window.location.host + '/config.json')
  .then(response => response.json())
  .catch(err => console.error(err))
  .then(res => {
    if (res) {
      setConfig({ ...res });
      // Enable redux logger if devMode is true
      if(res.devMode) {
        addMiddleware(createLogger());
      }
    }
  });
Example #9
Source File: store.js    From Conduit-Cypress with MIT License 6 votes vote down vote up
getMiddleware = () => {
  // we only collect code coverage in non-production environment
  // thus "IF" branch will never get hit
  /* istanbul ignore if */
  if (process.env.NODE_ENV === 'production') {
    return applyMiddleware(
      myRouterMiddleware,
      promiseMiddleware,
      localStorageMiddleware
    )
  } else {
    // Enable additional logging in non-production environments.
    return applyMiddleware(
      myRouterMiddleware,
      promiseMiddleware,
      localStorageMiddleware,
      createLogger()
    )
  }
}
Example #10
Source File: configureStore.dev.js    From Learning-Redux with MIT License 6 votes vote down vote up
configureStore = (preloadedState) => {
  const store = createStore(
    rootReducer,
    preloadedState,
    compose(applyMiddleware(thunk, api, createLogger()), DevTools.instrument())
  );

  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
    module.hot.accept("../reducers", () => {
      const nextRootReducer = require("../reducers").default;
      store.replaceReducer(nextRootReducer);
    });
  }

  return store;
}
Example #11
Source File: store.js    From erp-crm with MIT License 5 votes vote down vote up
logger = createLogger()
Example #12
Source File: store.js    From react-14.01 with MIT License 5 votes vote down vote up
logger = createLogger()
Example #13
Source File: store.js    From react-14.01 with MIT License 5 votes vote down vote up
logger =  createLogger ()
Example #14
Source File: store.js    From react-14.01 with MIT License 5 votes vote down vote up
logger = createLogger()
Example #15
Source File: store.js    From react-14.01 with MIT License 5 votes vote down vote up
logger = createLogger()
Example #16
Source File: store.js    From react-14.01 with MIT License 5 votes vote down vote up
logger = createLogger()
Example #17
Source File: store.js    From react-14.01 with MIT License 5 votes vote down vote up
logger = createLogger()
Example #18
Source File: store.js    From starter-antd-admin-crud-auth-mern with MIT License 5 votes vote down vote up
logger = createLogger()
Example #19
Source File: index.js    From test-automation-training with MIT License 5 votes vote down vote up
loggerMiddleware = createLogger()
Example #20
Source File: configureStore.js    From movies with MIT License 5 votes vote down vote up
function configureStore(initialState = {}, startSagas = false) {
  const sagaMiddleware = createSagaMiddleware();
  const middlewares = [sagaMiddleware];

  if (process.env.DEBUG_MODE === '1') {
    const logLevel = IS_CLIENT ? 'log' : false;
    const logger = createLogger({
      level: {
        prevState: logLevel,
        action: logLevel,
        nextState: logLevel
      },
      collapsed: (getState, action, logEntry) => !logEntry.error
    });

    middlewares.push(logger);
  }

  const store = createStore(
    rootReducer,
    initialState,
    compose(
      composeWithDevTools(applyMiddleware(...middlewares))
    )
  );

  // required for SSR fetching data
  store.runSaga = sagaMiddleware.run;
  store.close = () => store.dispatch(END);

  if (startSagas) {
    SagaManager.startSagas(sagaMiddleware);
  }

  // HMR for reducers and sagas
  /* eslint-disable global-require */
  if (process.env.NODE_ENV === 'development' && module.hot) {
    module.hot.accept('./rootReducer', () => {
      const nextRootReducer = require('./rootReducer').default;
      store.replaceReducer(nextRootReducer);
    });

    module.hot.accept('./sagas/SagaManager', () => {
      SagaManager.cancelSagas(store);
      require('./sagas/SagaManager').default.startSagas(sagaMiddleware);
    });
  }
  /* eslint-enable global-require */

  return store;
}
Example #21
Source File: store.js    From testconduit with MIT License 5 votes vote down vote up
getMiddleware = () => {
  if (process.env.NODE_ENV === 'production') {
    return applyMiddleware(myRouterMiddleware, promiseMiddleware, localStorageMiddleware);
  } else {
    // Enable additional logging in non-production environments.
    return applyMiddleware(myRouterMiddleware, promiseMiddleware, localStorageMiddleware, createLogger())
  }
}
Example #22
Source File: store.js    From react-admin-portal with MIT License 5 votes vote down vote up
loggerMiddleware = createLogger()
Example #23
Source File: index.jsx    From ResoBin with MIT License 5 votes vote down vote up
logger = createLogger({
  collapsed: (getState, action, logEntry) => !logEntry.error,
})
Example #24
Source File: store.dev.js    From xmrig-workers with GNU General Public License v3.0 5 votes vote down vote up
configureStore = (preloadedState) => createStore(
  createRootReducer(history),
  preloadedState,
  compose(
    applyMiddleware(thunk, createLogger(), routerMiddleware(history)),
    DevTools.instrument()
  )
)
Example #25
Source File: configureStore.dev.js    From brisque-2.0-desktop with MIT License 5 votes vote down vote up
configureStore = (initialState?: stateType) => {
  // Redux Configuration
  const middleware = [];
  const enhancers = [];

  // Thunk Middleware
  middleware.push(thunk);

  // Logging Middleware
  const logger = createLogger({
    level: 'info',
    collapsed: true
  });

  // Skip redux logs in console during the tests
  if (process.env.NODE_ENV !== 'test') {
    middleware.push(logger);
  }

  // Router Middleware
  const router = routerMiddleware(history);
  middleware.push(router);

  // Redux DevTools Configuration
  const actionCreators = {
    ...actions,
    ...routerActions
  };
  // If Redux DevTools Extension is installed use it, otherwise use Redux compose
  /* eslint-disable no-underscore-dangle */
  const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
    ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
        // Options: http://extension.remotedev.io/docs/API/Arguments.html
        actionCreators
      })
    : compose;
  /* eslint-enable no-underscore-dangle */

  // Apply Middleware & Compose Enhancers
  enhancers.push(applyMiddleware(...middleware));
  const enhancer = composeEnhancers(...enhancers);

  // Create Store
  const store = createStore(rootReducer, initialState, enhancer);

  return store;
}
Example #26
Source File: configure.js    From EthereumPonzi with MIT License 5 votes vote down vote up
loggerMiddleware = createLogger()
Example #27
Source File: store.js    From CyberStateRP with MIT License 5 votes vote down vote up
loggerMiddleware = createLogger()
Example #28
Source File: index.js    From neighborhood-chef-fe with MIT License 5 votes vote down vote up
logger = createLogger()
Example #29
Source File: store.js    From Designer-Client with GNU General Public License v3.0 5 votes vote down vote up
loggerMiddleware = createLogger()