2.6.0
Fine-grained control over level
π
Thankfully to @mathieudutour now we have very useful feature: fine-grained control over level
.
function
const logger = createLogger({
level: (action) => action.type === `SET_AUTH_TOKEN` ? `warning` : `log`
});
object
const logger = createLogger({
level: {
prevState: `log`,
action: `info`,
nextState: `log`,
error: `error`,
},
});
object with functions
const logger = createLogger({
level: {
prevState: false, // disable message of prevState
action: ({ type }) => type.indexOf(`redux-form`) > -1 ? false : `info`, // don't show messages from redux-form (sorry, erikras, it's for demo only!)
nextState: ({ type }) => type.indexOf(`user`) > -1 ? `warning` : `info`, // show nextState as warning if action is user-related
error: `error`,
},
});