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
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.
Default: console.log
logger (Object)
Implementation of the console
API. Useful if you are using a custom, wrapped version of console
.
Default: window.console
collapsed (Boolean)
Is group collapsed?
Default: false
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.
Default: null
(always log)
transform (Function)
Transform state before print. Eg. convert Immutable object to plain JSON.
Default: identity function
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