Skip to content

2.6.0

Compare
Choose a tag to compare
@imevro imevro released this 22 Feb 13:05
· 98 commits to master since this release

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`,
  },
});