|
|
|
@ -3,7 +3,11 @@ |
|
|
|
|
import Logger from 'jitsi-meet-logger'; |
|
|
|
|
|
|
|
|
|
import { APP_WILL_MOUNT } from '../app'; |
|
|
|
|
import JitsiMeetJS, { LIB_WILL_INIT } from '../lib-jitsi-meet'; |
|
|
|
|
import { CONFERENCE_JOINED, getCurrentConference } from '../conference'; |
|
|
|
|
import JitsiMeetJS, { |
|
|
|
|
LIB_WILL_INIT, |
|
|
|
|
JitsiConferenceEvents |
|
|
|
|
} from '../lib-jitsi-meet'; |
|
|
|
|
import { MiddlewareRegistry } from '../redux'; |
|
|
|
|
|
|
|
|
|
import JitsiMeetInMemoryLogStorage |
|
|
|
@ -12,6 +16,7 @@ import JitsiMeetLogStorage from '../../../../modules/util/JitsiMeetLogStorage'; |
|
|
|
|
|
|
|
|
|
import { isTestModeEnabled } from '../testing'; |
|
|
|
|
|
|
|
|
|
import { setLogCollector } from './actions'; |
|
|
|
|
import { SET_LOGGING_CONFIG } from './actionTypes'; |
|
|
|
|
|
|
|
|
|
declare var APP: Object; |
|
|
|
@ -28,6 +33,9 @@ MiddlewareRegistry.register(store => next => action => { |
|
|
|
|
case APP_WILL_MOUNT: |
|
|
|
|
return _appWillMount(store, next, action); |
|
|
|
|
|
|
|
|
|
case CONFERENCE_JOINED: |
|
|
|
|
return _conferenceJoined(store, next, action); |
|
|
|
|
|
|
|
|
|
case LIB_WILL_INIT: |
|
|
|
|
return _libWillInit(store, next, action); |
|
|
|
|
|
|
|
|
@ -66,28 +74,83 @@ function _appWillMount({ getState }, next, action) { |
|
|
|
|
return next(action); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Starts the log collector, after {@link CONFERENCE_JOINED} action is reduced. |
|
|
|
|
* |
|
|
|
|
* @param {Store} store - The Redux store in which the specified {@code action} |
|
|
|
|
* is being dispatched. |
|
|
|
|
* @param {Dispatch} next - The Redux {@code dispatch} function to dispatch the |
|
|
|
|
* specified {@code action} to the specified {@code store}. |
|
|
|
|
* @param {Action} action - The Redux action {@code CONFERENCE_JOINED} which is |
|
|
|
|
* being dispatched in the specified {@code store}. |
|
|
|
|
* @private |
|
|
|
|
* @returns {*} |
|
|
|
|
*/ |
|
|
|
|
function _conferenceJoined({ getState }, next, action) { |
|
|
|
|
|
|
|
|
|
// Wait until the joined event is processed, so that the JitsiMeetLogStorage
|
|
|
|
|
// will be ready.
|
|
|
|
|
const result = next(action); |
|
|
|
|
|
|
|
|
|
const { conference } = action; |
|
|
|
|
const { logCollector } = getState()['features/base/logging']; |
|
|
|
|
|
|
|
|
|
if (logCollector && conference === getCurrentConference(getState())) { |
|
|
|
|
// Start the LogCollector's periodic "store logs" task
|
|
|
|
|
logCollector.start(); |
|
|
|
|
|
|
|
|
|
// Make an attempt to flush in case a lot of logs have been cached,
|
|
|
|
|
// before the collector was started.
|
|
|
|
|
logCollector.flush(); |
|
|
|
|
|
|
|
|
|
// This event listener will flush the logs, before the statistics module
|
|
|
|
|
// (CallStats) is stopped.
|
|
|
|
|
//
|
|
|
|
|
// NOTE The LogCollector is not stopped, because this event can be
|
|
|
|
|
// triggered multiple times during single conference (whenever
|
|
|
|
|
// statistics module is stopped). That includes the case when Jicofo
|
|
|
|
|
// terminates a single person conference (one person left in the room
|
|
|
|
|
// waiting for someone to join). It will then restart the media session
|
|
|
|
|
// when someone eventually joins the room which will start the stats
|
|
|
|
|
// again.
|
|
|
|
|
conference.on( |
|
|
|
|
JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED, |
|
|
|
|
() => logCollector.flush() |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Initializes logging in the app. |
|
|
|
|
* |
|
|
|
|
* @param {Store} store - The Redux store in which context the logging is to be |
|
|
|
|
* initialized. |
|
|
|
|
* @param {Object} loggingConfig - The configuration with which logging is to be |
|
|
|
|
* initialized. |
|
|
|
|
* @param {boolean} isTestingEnabled - Is debug logging enabled. |
|
|
|
|
* @private |
|
|
|
|
* @returns {void} |
|
|
|
|
*/ |
|
|
|
|
function _initLogging(loggingConfig, isTestingEnabled) { |
|
|
|
|
function _initLogging({ dispatch, getState }, loggingConfig, isTestingEnabled) { |
|
|
|
|
const { logCollector } = getState()['features/base/logging']; |
|
|
|
|
|
|
|
|
|
// Create the LogCollector and register it as the global log transport. It
|
|
|
|
|
// is done early to capture as much logs as possible. Captured logs will be
|
|
|
|
|
// cached, before the JitsiMeetLogStorage gets ready (statistics module is
|
|
|
|
|
// initialized).
|
|
|
|
|
if (typeof APP === 'object' |
|
|
|
|
&& !APP.logCollector |
|
|
|
|
&& !loggingConfig.disableLogCollector) { |
|
|
|
|
APP.logCollector = new Logger.LogCollector(new JitsiMeetLogStorage()); |
|
|
|
|
Logger.addGlobalTransport(APP.logCollector); |
|
|
|
|
JitsiMeetJS.addGlobalLogTransport(APP.logCollector); |
|
|
|
|
|
|
|
|
|
if (isTestingEnabled) { |
|
|
|
|
if (!logCollector && !loggingConfig.disableLogCollector) { |
|
|
|
|
const _logCollector |
|
|
|
|
= new Logger.LogCollector(new JitsiMeetLogStorage(getState)); |
|
|
|
|
|
|
|
|
|
Logger.addGlobalTransport(_logCollector); |
|
|
|
|
JitsiMeetJS.addGlobalLogTransport(_logCollector); |
|
|
|
|
dispatch(setLogCollector(_logCollector)); |
|
|
|
|
|
|
|
|
|
// The JitsiMeetInMemoryLogStorage can not be accessed on mobile through
|
|
|
|
|
// the 'executeScript' method like it's done in torture tests for WEB.
|
|
|
|
|
if (isTestingEnabled && typeof APP === 'object') { |
|
|
|
|
APP.debugLogs = new JitsiMeetInMemoryLogStorage(); |
|
|
|
|
const debugLogCollector = new Logger.LogCollector( |
|
|
|
|
APP.debugLogs, { storeInterval: 1000 }); |
|
|
|
@ -96,6 +159,11 @@ function _initLogging(loggingConfig, isTestingEnabled) { |
|
|
|
|
JitsiMeetJS.addGlobalLogTransport(debugLogCollector); |
|
|
|
|
debugLogCollector.start(); |
|
|
|
|
} |
|
|
|
|
} else if (logCollector && loggingConfig.disableLogCollector) { |
|
|
|
|
Logger.removeGlobalTransport(logCollector); |
|
|
|
|
JitsiMeetJS.removeGlobalLogTransport(logCollector); |
|
|
|
|
logCollector.stop(); |
|
|
|
|
dispatch(setLogCollector(undefined)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -137,7 +205,7 @@ function _libWillInit({ getState }, next, action) { |
|
|
|
|
* @returns {Object} The new state that is the result of the reduction of the |
|
|
|
|
* specified {@code action}. |
|
|
|
|
*/ |
|
|
|
|
function _setLoggingConfig({ getState }, next, action) { |
|
|
|
|
function _setLoggingConfig({ dispatch, getState }, next, action) { |
|
|
|
|
const result = next(action); |
|
|
|
|
const newValue = getState()['features/base/logging'].config; |
|
|
|
|
const isTestingEnabled = isTestModeEnabled(getState()); |
|
|
|
@ -151,7 +219,10 @@ function _setLoggingConfig({ getState }, next, action) { |
|
|
|
|
_setLogLevels(Logger, newValue); |
|
|
|
|
_setLogLevels(JitsiMeetJS, newValue); |
|
|
|
|
|
|
|
|
|
_initLogging(newValue, isTestingEnabled); |
|
|
|
|
_initLogging({ |
|
|
|
|
dispatch, |
|
|
|
|
getState |
|
|
|
|
}, newValue, isTestingEnabled); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|