Redux-logger-filter
is a helper module to provide filter function to redux-logger
.
You can configure Redux-logger
to log only certain actions.
npm i -D redux-logger-filter
Use the predicate
parameter of the createLogger
function.
import { applyMiddleware, createStore } from 'redux';
import { createLogger } from 'redux-logger';
import { makeLogFilter } from 'redux-logger-filter';
// Set to log only 'INCREASE' and 'DECREASE'.
const logger = createLogger({
predicate: makeLogFilter('INCREASE', 'DECREASE'),
});
const store = createStore(reducer, applyMiddleware(logger));
// You can pass it in array.
const filterList = ['counter/INCREASE', 'counter/DECREASE'];
const logger = createLogger({
predicate: makeLogFilter(filterList)
});
// You can also put Action Creator directly.
import { increase, decrease } from './modules/counter.js';
const logger = createLogger({
predicate: makeLogFilter(increase, decrease)
});
const logger = createLogger({
predicate: makeLogFilter([increase, decrease])
});
// Action Objects
const logger = createLogger({
predicate: makeLogFilter(increase(), decrease())
});
*/
You can also exclude certain actions.
import { createLogger } from 'redux-logger';
import { makeLogFilter, excludeFilter } from 'redux-logger-filter';
const filter = makeLogFilter('INCREASE', 'DECREASE');
const logger = createLogger({
predicate: excludeFilter(filter) // Excludes INCREASE and DECREASE actions.
});
BitYounjgae ([email protected])
MIT