redux-cli-logger
A redux logger for command-line environments (node.js)
No innovations here, just a logger middleware for
redux that will write all redux actions and
state changes to the node.js console.
Configuration and output format inspired by redux-logger
Installation
npm install --save-dev redux-cli-logger
Usage
redux-cli-logger must be called as a function before being utilized as
middleware. This allows passing in options to overwrite all colors and arrow
icons, as well as a predicate that functions like that in redux-logger. Here's
what a simple configureStore function might look like:
import reducer from '../reducers'
import createCLILogger from 'redux-cli-logger'
const middleware = [
]
if (process.env.NODE_ENV === 'development') {
const loggerOptions = {
predicate: (getState, action) => !action.MONITOR_ACTION
}
const logger = createCLILogger(loggerOptions)
middleware.push(logger)
}
const enhancer = compose(
applyMiddleware(...middleware)
)
const initialState = {}
const store = createStore(reducer, initialState, enhancer)
Configuration
The options object has overridable defaults that look like this:
{
downArrow: '▼',
rightArrow: '▶',
messageColor: 'bright-yellow',
prevColor: 'grey',
actionColor: 'bright-blue',
nextColor: 'green',
predicate: ''
}