2018-02-14 18:28:22 +00:00
|
|
|
// @flow
|
|
|
|
|
2017-04-23 20:17:31 +00:00
|
|
|
import { equals, ReducerRegistry } from '../redux';
|
|
|
|
|
|
|
|
import { SET_LOGGING_CONFIG } from './actionTypes';
|
|
|
|
|
|
|
|
/**
|
2018-02-14 18:28:22 +00:00
|
|
|
* The default/initial redux state of the feature base/logging.
|
2017-04-23 20:17:31 +00:00
|
|
|
*
|
2018-02-14 18:28:22 +00:00
|
|
|
* XXX When making any changes to the DEFAULT_STATE make sure to also update
|
2018-01-17 18:59:48 +00:00
|
|
|
* logging_config.js file located in the root directory of this project !!!
|
|
|
|
*
|
2017-04-23 20:17:31 +00:00
|
|
|
* @type {{
|
|
|
|
* config: Object
|
|
|
|
* }}
|
|
|
|
*/
|
2018-02-14 18:28:22 +00:00
|
|
|
const DEFAULT_STATE = {
|
2017-04-23 20:17:31 +00:00
|
|
|
config: {
|
|
|
|
defaultLogLevel: 'trace',
|
|
|
|
|
|
|
|
// The following are too verbose in their logging with the
|
|
|
|
// {@link #defaultLogLevel}:
|
|
|
|
'modules/statistics/CallStats.js': 'info',
|
2018-01-17 18:59:48 +00:00
|
|
|
'modules/xmpp/strophe.util.js': 'log',
|
|
|
|
'modules/RTC/TraceablePeerConnection.js': 'info'
|
2017-04-23 20:17:31 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ReducerRegistry.register(
|
|
|
|
'features/base/logging',
|
2018-02-14 18:28:22 +00:00
|
|
|
(state = DEFAULT_STATE, action) => {
|
2017-04-23 20:17:31 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case SET_LOGGING_CONFIG:
|
|
|
|
return _setLoggingConfig(state, action);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reduces a specific Redux action SET_LOGGING_CONFIG of the feature
|
|
|
|
* base/logging.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state of the feature base/logging.
|
|
|
|
* @param {Action} action - The Redux action SET_LOGGING_CONFIG to reduce.
|
|
|
|
* @private
|
|
|
|
* @returns {Object} The new state of the feature base/logging after the
|
|
|
|
* reduction of the specified action.
|
|
|
|
*/
|
|
|
|
function _setLoggingConfig(state, action) {
|
|
|
|
const config = {
|
2018-02-14 18:28:22 +00:00
|
|
|
// The config of DEFAULT_STATE is the default configuration of the
|
2017-04-23 20:17:31 +00:00
|
|
|
// feature base/logging.
|
2018-02-14 18:28:22 +00:00
|
|
|
...DEFAULT_STATE.config,
|
2017-04-23 20:17:31 +00:00
|
|
|
...action.config
|
|
|
|
};
|
|
|
|
|
|
|
|
if (equals(state.config, config)) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
config
|
|
|
|
};
|
|
|
|
}
|