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

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