It's more friendly for newcomers and now recommended way to use redux-logger.
So, you can import default logger and use it with default options:
import { logger } from 'redux-logger'
const store = createStore(
reducer,
applyMiddleware(logger)
)
Changelog
- expose default logger (
import { logger } from 'redux-logger
) - expose default settings (
import { defaults } from 'redux-logger
): useful if you use customcolors
object and tired type default settings.
Instead of
import createLogger from 'redux-logger'
const logger = createLogger({
colors: {
prevState: () => `#9E9E9E`,
action: () => `#03A9F4`,
nextState: () => `#4CAF50`,
error: () => `#F20404`,
title: ({ type }) => {
if (type.indexOf(`started`) > -1) return `orange`;
if (type.indexOf(`failed`) > -1) return `#F20404`;
if (type.indexOf(`succeeded`) > -1) return `#4CAF50`;
if (type.indexOf(`update`) > -1) return `#03A9F4`;
return `inherit`;
}
}
})
you can
import createLogger, { defaults } from 'redux-logger'
const logger = createLogger({
colors: {
...defaults.colors,
title: ({ type }) => {
if (type.indexOf(`started`) > -1) return `orange`;
if (type.indexOf(`failed`) > -1) return `#F20404`;
if (type.indexOf(`succeeded`) > -1) return `#4CAF50`;
if (type.indexOf(`update`) > -1) return `#03A9F4`;
return `inherit`;
}
}
})