Browse Source

ref(LogCollector): adapts to caching in LogCollector

j8
paweldomas 9 years ago
parent
commit
3475ad4674
2 changed files with 37 additions and 17 deletions
  1. 23
    10
      app.js
  2. 14
    7
      modules/util/JitsiMeetLogStorage.js

+ 23
- 10
app.js View File

162
     initLogging () {
162
     initLogging () {
163
         // Adjust logging level
163
         // Adjust logging level
164
         configureLoggingLevels();
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
         if (!this.logCollector && !loggingConfig.disableLogCollector) {
169
         if (!this.logCollector && !loggingConfig.disableLogCollector) {
167
             this.logCollector = new LogCollector(new JitsiMeetLogStorage());
170
             this.logCollector = new LogCollector(new JitsiMeetLogStorage());
168
             Logger.addGlobalTransport(this.logCollector);
171
             Logger.addGlobalTransport(this.logCollector);
189
     APP.ConferenceUrl = new ConferenceUrl(window.location);
192
     APP.ConferenceUrl = new ConferenceUrl(window.location);
190
     // Clean up the URL displayed by the browser
193
     // Clean up the URL displayed by the browser
191
     replaceHistoryState(APP.ConferenceUrl.getInviteUrl());
194
     replaceHistoryState(APP.ConferenceUrl.getInviteUrl());
192
-    var isUIReady = APP.UI.start();
195
+    const isUIReady = APP.UI.start();
193
     if (isUIReady) {
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
         APP.conference.init({roomName: buildRoomName()}).then(function () {
197
         APP.conference.init({roomName: buildRoomName()}).then(function () {
202
 
198
 
203
-            // Will flush the logs, before the stats are disposed
204
             if (APP.logCollector) {
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
                 APP.conference.addConferenceListener(
218
                 APP.conference.addConferenceListener(
206
                     ConferenceEvents.BEFORE_STATISTICS_DISPOSED,
219
                     ConferenceEvents.BEFORE_STATISTICS_DISPOSED,
207
                     () => {
220
                     () => {

+ 14
- 7
modules/util/JitsiMeetLogStorage.js View File

16
         this.counter = 1;
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
      * Called by the <tt>LogCollector</tt> to store a series of log lines into
28
      * Called by the <tt>LogCollector</tt> to store a series of log lines into
21
      * batch.
29
      * batch.
24
      */
32
      */
25
     storeLogs(logEntries) {
33
     storeLogs(logEntries) {
26
 
34
 
35
+        if (!APP.conference.isCallstatsEnabled()) {
36
+            // Discard the logs if CallStats is not enabled.
37
+            return;
38
+        }
39
+
27
         let logJSON = '{"log' + this.counter + '":"\n';
40
         let logJSON = '{"log' + this.counter + '":"\n';
28
         for (let i = 0, len = logEntries.length; i < len; i++) {
41
         for (let i = 0, len = logEntries.length; i < len; i++) {
29
             let logEntry = logEntries[i];
42
             let logEntry = logEntries[i];
43
         // on the way that could be uninitialized if the storeLogs
56
         // on the way that could be uninitialized if the storeLogs
44
         // attempt would be made very early (which is unlikely)
57
         // attempt would be made very early (which is unlikely)
45
         try {
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
         } catch (error) {
60
         } catch (error) {
54
             // NOTE console is intentional here
61
             // NOTE console is intentional here
55
             console.error(
62
             console.error(

Loading…
Cancel
Save