|
@@ -3,7 +3,11 @@
|
3
|
3
|
import Logger from 'jitsi-meet-logger';
|
4
|
4
|
|
5
|
5
|
import { APP_WILL_MOUNT } from '../app';
|
6
|
|
-import JitsiMeetJS, { LIB_WILL_INIT } from '../lib-jitsi-meet';
|
|
6
|
+import { CONFERENCE_JOINED, getCurrentConference } from '../conference';
|
|
7
|
+import JitsiMeetJS, {
|
|
8
|
+ LIB_WILL_INIT,
|
|
9
|
+ JitsiConferenceEvents
|
|
10
|
+} from '../lib-jitsi-meet';
|
7
|
11
|
import { MiddlewareRegistry } from '../redux';
|
8
|
12
|
|
9
|
13
|
import JitsiMeetInMemoryLogStorage
|
|
@@ -12,6 +16,7 @@ import JitsiMeetLogStorage from '../../../../modules/util/JitsiMeetLogStorage';
|
12
|
16
|
|
13
|
17
|
import { isTestModeEnabled } from '../testing';
|
14
|
18
|
|
|
19
|
+import { setLogCollector } from './actions';
|
15
|
20
|
import { SET_LOGGING_CONFIG } from './actionTypes';
|
16
|
21
|
|
17
|
22
|
declare var APP: Object;
|
|
@@ -28,6 +33,9 @@ MiddlewareRegistry.register(store => next => action => {
|
28
|
33
|
case APP_WILL_MOUNT:
|
29
|
34
|
return _appWillMount(store, next, action);
|
30
|
35
|
|
|
36
|
+ case CONFERENCE_JOINED:
|
|
37
|
+ return _conferenceJoined(store, next, action);
|
|
38
|
+
|
31
|
39
|
case LIB_WILL_INIT:
|
32
|
40
|
return _libWillInit(store, next, action);
|
33
|
41
|
|
|
@@ -66,28 +74,83 @@ function _appWillMount({ getState }, next, action) {
|
66
|
74
|
return next(action);
|
67
|
75
|
}
|
68
|
76
|
|
|
77
|
+/**
|
|
78
|
+ * Starts the log collector, after {@link CONFERENCE_JOINED} action is reduced.
|
|
79
|
+ *
|
|
80
|
+ * @param {Store} store - The Redux store in which the specified {@code action}
|
|
81
|
+ * is being dispatched.
|
|
82
|
+ * @param {Dispatch} next - The Redux {@code dispatch} function to dispatch the
|
|
83
|
+ * specified {@code action} to the specified {@code store}.
|
|
84
|
+ * @param {Action} action - The Redux action {@code CONFERENCE_JOINED} which is
|
|
85
|
+ * being dispatched in the specified {@code store}.
|
|
86
|
+ * @private
|
|
87
|
+ * @returns {*}
|
|
88
|
+ */
|
|
89
|
+function _conferenceJoined({ getState }, next, action) {
|
|
90
|
+
|
|
91
|
+ // Wait until the joined event is processed, so that the JitsiMeetLogStorage
|
|
92
|
+ // will be ready.
|
|
93
|
+ const result = next(action);
|
|
94
|
+
|
|
95
|
+ const { conference } = action;
|
|
96
|
+ const { logCollector } = getState()['features/base/logging'];
|
|
97
|
+
|
|
98
|
+ if (logCollector && conference === getCurrentConference(getState())) {
|
|
99
|
+ // Start the LogCollector's periodic "store logs" task
|
|
100
|
+ logCollector.start();
|
|
101
|
+
|
|
102
|
+ // Make an attempt to flush in case a lot of logs have been cached,
|
|
103
|
+ // before the collector was started.
|
|
104
|
+ logCollector.flush();
|
|
105
|
+
|
|
106
|
+ // This event listener will flush the logs, before the statistics module
|
|
107
|
+ // (CallStats) is stopped.
|
|
108
|
+ //
|
|
109
|
+ // NOTE The LogCollector is not stopped, because this event can be
|
|
110
|
+ // triggered multiple times during single conference (whenever
|
|
111
|
+ // statistics module is stopped). That includes the case when Jicofo
|
|
112
|
+ // terminates a single person conference (one person left in the room
|
|
113
|
+ // waiting for someone to join). It will then restart the media session
|
|
114
|
+ // when someone eventually joins the room which will start the stats
|
|
115
|
+ // again.
|
|
116
|
+ conference.on(
|
|
117
|
+ JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED,
|
|
118
|
+ () => logCollector.flush()
|
|
119
|
+ );
|
|
120
|
+ }
|
|
121
|
+
|
|
122
|
+ return result;
|
|
123
|
+}
|
|
124
|
+
|
69
|
125
|
/**
|
70
|
126
|
* Initializes logging in the app.
|
71
|
127
|
*
|
|
128
|
+ * @param {Store} store - The Redux store in which context the logging is to be
|
|
129
|
+ * initialized.
|
72
|
130
|
* @param {Object} loggingConfig - The configuration with which logging is to be
|
73
|
131
|
* initialized.
|
74
|
132
|
* @param {boolean} isTestingEnabled - Is debug logging enabled.
|
75
|
133
|
* @private
|
76
|
134
|
* @returns {void}
|
77
|
135
|
*/
|
78
|
|
-function _initLogging(loggingConfig, isTestingEnabled) {
|
|
136
|
+function _initLogging({ dispatch, getState }, loggingConfig, isTestingEnabled) {
|
|
137
|
+ const { logCollector } = getState()['features/base/logging'];
|
|
138
|
+
|
79
|
139
|
// Create the LogCollector and register it as the global log transport. It
|
80
|
140
|
// is done early to capture as much logs as possible. Captured logs will be
|
81
|
141
|
// cached, before the JitsiMeetLogStorage gets ready (statistics module is
|
82
|
142
|
// initialized).
|
83
|
|
- if (typeof APP === 'object'
|
84
|
|
- && !APP.logCollector
|
85
|
|
- && !loggingConfig.disableLogCollector) {
|
86
|
|
- APP.logCollector = new Logger.LogCollector(new JitsiMeetLogStorage());
|
87
|
|
- Logger.addGlobalTransport(APP.logCollector);
|
88
|
|
- JitsiMeetJS.addGlobalLogTransport(APP.logCollector);
|
89
|
|
-
|
90
|
|
- if (isTestingEnabled) {
|
|
143
|
+ if (!logCollector && !loggingConfig.disableLogCollector) {
|
|
144
|
+ const _logCollector
|
|
145
|
+ = new Logger.LogCollector(new JitsiMeetLogStorage(getState));
|
|
146
|
+
|
|
147
|
+ Logger.addGlobalTransport(_logCollector);
|
|
148
|
+ JitsiMeetJS.addGlobalLogTransport(_logCollector);
|
|
149
|
+ dispatch(setLogCollector(_logCollector));
|
|
150
|
+
|
|
151
|
+ // The JitsiMeetInMemoryLogStorage can not be accessed on mobile through
|
|
152
|
+ // the 'executeScript' method like it's done in torture tests for WEB.
|
|
153
|
+ if (isTestingEnabled && typeof APP === 'object') {
|
91
|
154
|
APP.debugLogs = new JitsiMeetInMemoryLogStorage();
|
92
|
155
|
const debugLogCollector = new Logger.LogCollector(
|
93
|
156
|
APP.debugLogs, { storeInterval: 1000 });
|
|
@@ -96,6 +159,11 @@ function _initLogging(loggingConfig, isTestingEnabled) {
|
96
|
159
|
JitsiMeetJS.addGlobalLogTransport(debugLogCollector);
|
97
|
160
|
debugLogCollector.start();
|
98
|
161
|
}
|
|
162
|
+ } else if (logCollector && loggingConfig.disableLogCollector) {
|
|
163
|
+ Logger.removeGlobalTransport(logCollector);
|
|
164
|
+ JitsiMeetJS.removeGlobalLogTransport(logCollector);
|
|
165
|
+ logCollector.stop();
|
|
166
|
+ dispatch(setLogCollector(undefined));
|
99
|
167
|
}
|
100
|
168
|
}
|
101
|
169
|
|
|
@@ -137,7 +205,7 @@ function _libWillInit({ getState }, next, action) {
|
137
|
205
|
* @returns {Object} The new state that is the result of the reduction of the
|
138
|
206
|
* specified {@code action}.
|
139
|
207
|
*/
|
140
|
|
-function _setLoggingConfig({ getState }, next, action) {
|
|
208
|
+function _setLoggingConfig({ dispatch, getState }, next, action) {
|
141
|
209
|
const result = next(action);
|
142
|
210
|
const newValue = getState()['features/base/logging'].config;
|
143
|
211
|
const isTestingEnabled = isTestModeEnabled(getState());
|
|
@@ -151,7 +219,10 @@ function _setLoggingConfig({ getState }, next, action) {
|
151
|
219
|
_setLogLevels(Logger, newValue);
|
152
|
220
|
_setLogLevels(JitsiMeetJS, newValue);
|
153
|
221
|
|
154
|
|
- _initLogging(newValue, isTestingEnabled);
|
|
222
|
+ _initLogging({
|
|
223
|
+ dispatch,
|
|
224
|
+ getState
|
|
225
|
+ }, newValue, isTestingEnabled);
|
155
|
226
|
|
156
|
227
|
return result;
|
157
|
228
|
}
|