You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reducer.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { equals, ReducerRegistry } from '../redux';
  2. import { SET_LOGGING_CONFIG } from './actionTypes';
  3. /**
  4. * The initial state of the feature base/logging.
  5. *
  6. * XXX When making any changes to the INITIAL_STATE make sure to also update
  7. * logging_config.js file located in the root directory of this project !!!
  8. *
  9. * @type {{
  10. * config: Object
  11. * }}
  12. */
  13. const INITIAL_STATE = {
  14. config: {
  15. defaultLogLevel: 'trace',
  16. // The following are too verbose in their logging with the
  17. // {@link #defaultLogLevel}:
  18. 'modules/statistics/CallStats.js': 'info',
  19. 'modules/xmpp/strophe.util.js': 'log',
  20. 'modules/RTC/TraceablePeerConnection.js': 'info'
  21. }
  22. };
  23. ReducerRegistry.register(
  24. 'features/base/logging',
  25. (state = INITIAL_STATE, action) => {
  26. switch (action.type) {
  27. case SET_LOGGING_CONFIG:
  28. return _setLoggingConfig(state, action);
  29. default:
  30. return state;
  31. }
  32. });
  33. /**
  34. * Reduces a specific Redux action SET_LOGGING_CONFIG of the feature
  35. * base/logging.
  36. *
  37. * @param {Object} state - The Redux state of the feature base/logging.
  38. * @param {Action} action - The Redux action SET_LOGGING_CONFIG to reduce.
  39. * @private
  40. * @returns {Object} The new state of the feature base/logging after the
  41. * reduction of the specified action.
  42. */
  43. function _setLoggingConfig(state, action) {
  44. const config = {
  45. // The config of INITIAL_STATE is the default configuration of the
  46. // feature base/logging.
  47. ...INITIAL_STATE.config,
  48. ...action.config
  49. };
  50. if (equals(state.config, config)) {
  51. return state;
  52. }
  53. return {
  54. ...state,
  55. config
  56. };
  57. }