All files / src/domain/createLoggerMiddleware index.js

100% Statements 10/10
100% Branches 4/4
100% Functions 4/4
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23          4x 4x 1x     3x 2x 2x   1x     2x          
import { createLogger } from 'redux-logger';
import log from 'domain/log';
import Config from 'domain/Config';
 
export function createLoggerMiddleware() {
  const sentry = Config.get('sentry');
  if (sentry && sentry.disabled === true) {
    return createLogger();
  }
 
  return () => (next) => (action) => {
    try {
      log.debug('Dispatched action:', JSON.stringify(action, null, 2));
    } catch (e) {
      log.warn('Could not log action:', e);
    }
 
    return next(action);
  };
}
 
export default createLoggerMiddleware;