Преглед на файлове

ref(LogCollector): adapts to caching in LogCollector

master
paweldomas преди 9 години
родител
ревизия
3475ad4674
променени са 2 файла, в които са добавени 37 реда и са изтрити 17 реда
  1. 23
    10
      app.js
  2. 14
    7
      modules/util/JitsiMeetLogStorage.js

+ 23
- 10
app.js Целия файл

@@ -162,7 +162,10 @@ const APP = {
162 162
     initLogging () {
163 163
         // Adjust logging level
164 164
         configureLoggingLevels();
165
-        // Start the LogCollector and register it as the global log transport
165
+        // Create the LogCollector and register it as the global log transport.
166
+        // It is done early to capture as much logs as possible. Captured logs
167
+        // will be cached, before the JitsiMeetLogStorage gets ready (statistics
168
+        // module is initialized).
166 169
         if (!this.logCollector && !loggingConfig.disableLogCollector) {
167 170
             this.logCollector = new LogCollector(new JitsiMeetLogStorage());
168 171
             Logger.addGlobalTransport(this.logCollector);
@@ -189,19 +192,29 @@ function init() {
189 192
     APP.ConferenceUrl = new ConferenceUrl(window.location);
190 193
     // Clean up the URL displayed by the browser
191 194
     replaceHistoryState(APP.ConferenceUrl.getInviteUrl());
192
-    var isUIReady = APP.UI.start();
195
+    const isUIReady = APP.UI.start();
193 196
     if (isUIReady) {
194
-        // Start the LogCollector's periodic "store logs" task only if we're in
195
-        // the conference and not on the welcome page.
196
-        if (APP.logCollector) {
197
-            APP.logCollector.start();
198
-            APP.logCollectorStarted = true;
199
-        }
200
-
201 197
         APP.conference.init({roomName: buildRoomName()}).then(function () {
202 198
 
203
-            // Will flush the logs, before the stats are disposed
204 199
             if (APP.logCollector) {
200
+                // Start the LogCollector's periodic "store logs" task only if
201
+                // we're in the conference and not on the welcome page. This is
202
+                // determined by the value of "isUIReady" const above.
203
+                APP.logCollector.start();
204
+                APP.logCollectorStarted = true;
205
+                // Make an attempt to flush in case a lot of logs have been
206
+                // cached, before the collector was started.
207
+                APP.logCollector.flush();
208
+
209
+                // This event listener will flush the logs, before
210
+                // the statistics module (CallStats) is stopped.
211
+                //
212
+                // NOTE The LogCollector is not stopped, because this event can
213
+                // be triggered multiple times during single conference
214
+                // (whenever statistics module is stopped). That includes
215
+                // the case when Jicofo terminates the single person left in the
216
+                // room. It will then restart the media session when someone
217
+                // eventually join the room which will start the stats again.
205 218
                 APP.conference.addConferenceListener(
206 219
                     ConferenceEvents.BEFORE_STATISTICS_DISPOSED,
207 220
                     () => {

+ 14
- 7
modules/util/JitsiMeetLogStorage.js Целия файл

@@ -16,6 +16,14 @@ export default class JitsiMeetLogStorage {
16 16
         this.counter = 1;
17 17
     }
18 18
 
19
+    /**
20
+     * @return {boolean} <tt>true</tt> when this storage is ready or
21
+     * <tt>false</tt> otherwise.
22
+     */
23
+    isReady() {
24
+        return APP.logCollectorStarted && APP.conference;
25
+    }
26
+
19 27
     /**
20 28
      * Called by the <tt>LogCollector</tt> to store a series of log lines into
21 29
      * batch.
@@ -24,6 +32,11 @@ export default class JitsiMeetLogStorage {
24 32
      */
25 33
     storeLogs(logEntries) {
26 34
 
35
+        if (!APP.conference.isCallstatsEnabled()) {
36
+            // Discard the logs if CallStats is not enabled.
37
+            return;
38
+        }
39
+
27 40
         let logJSON = '{"log' + this.counter + '":"\n';
28 41
         for (let i = 0, len = logEntries.length; i < len; i++) {
29 42
             let logEntry = logEntries[i];
@@ -43,13 +56,7 @@ export default class JitsiMeetLogStorage {
43 56
         // on the way that could be uninitialized if the storeLogs
44 57
         // attempt would be made very early (which is unlikely)
45 58
         try {
46
-            // Currently it makes sense to store the log only
47
-            // if CallStats is enabled
48
-            if (APP.logCollectorStarted
49
-                    && APP.conference
50
-                    && APP.conference.isCallstatsEnabled()) {
51
-                APP.conference.logJSON(logJSON);
52
-            }
59
+            APP.conference.logJSON(logJSON);
53 60
         } catch (error) {
54 61
             // NOTE console is intentional here
55 62
             console.error(

Loading…
Отказ
Запис