JSPM

  • Created
  • Published
  • Downloads 849352
  • Score
    100M100P100Q176292F
  • License MIT

Logger for redux

Package Exports

  • redux-logger

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redux-logger) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Logger for redux

logger

Install

npm i --save redux-logger

Usage

import createLogger from 'redux-logger';

const logger = createLogger();
const createStoreWithMiddleware = applyMiddleware(logger)(createStore);
const store = createStoreWithMiddleware(reducer);

API

redux-logger exposes single constructor function for creating logger middleware.

createLogger(options?: Object)

Options

level (String)

Level of console. warn, error, info or else.

logger (Object)

Implementation of the console API. Useful if you are using a custom, wrapped version of console.

collapsed (Boolean)

Is group collapsed?

predicate (getState: Function, action: Object): boolean

If specified this function will be called before each action is processed with this middleware. Receives getState function for accessing current store state and action object as parameters. Returns true if action should be logged, false otherwise.

Examples:
log only in dev mode
const __DEV__ = true;

createLogger({
  predicate: (getState, action) => __DEV__
});
log everything except actions with type AUTH_REMOVE_TOKEN
createLogger({
  predicate: (getState, action) => action.type !== AUTH_REMOVE_TOKEN
});

License

MIT