Browse Source

Changes the logger from console to jitsi-meet-logger

dev1
hristoterezov 10 years ago
parent
commit
e1cc5e5aac

+ 3
- 1
JitsiConference.js View File

@@ -1,3 +1,5 @@
1
+
2
+var logger = require("jitsi-meet-logger").getLogger(__filename);
1 3
 var RTC = require("./modules/RTC/RTC");
2 4
 var XMPPEvents = require("./service/xmpp/XMPPEvents");
3 5
 var StreamEventTypes = require("./service/RTC/StreamEventTypes");
@@ -19,7 +21,7 @@ var Statistics = require("./modules/statistics/statistics");
19 21
 
20 22
 function JitsiConference(options) {
21 23
     if(!options.name || options.name.toLowerCase() !== options.name) {
22
-        console.error("Invalid conference name (no conference name passed or it"
24
+        logger.error("Invalid conference name (no conference name passed or it"
23 25
             + "contains invalid characters like capital letters)!");
24 26
          return;
25 27
     }

+ 6
- 1
JitsiMeetJS.js View File

@@ -3,6 +3,7 @@ var JitsiConferenceEvents = require("./JitsiConferenceEvents");
3 3
 var JitsiConnectionEvents = require("./JitsiConnectionEvents");
4 4
 var JitsiConnectionErrors = require("./JitsiConnectionErrors");
5 5
 var JitsiConferenceErrors = require("./JitsiConferenceErrors");
6
+var Logger = require("jitsi-meet-logger");
6 7
 
7 8
 /**
8 9
  * Namespace for the interface of Jitsi Meet Library.
@@ -18,11 +19,15 @@ var LibJitsiMeet = {
18 19
         conference: JitsiConferenceErrors,
19 20
         connection: JitsiConnectionErrors
20 21
     },
22
+    logLevels: Logger.levels,
21 23
     init: function (options) {
22 24
         require("./modules/RTC/RTC").init(options || {});
25
+    },
26
+    setLogLevel: function (level) {
27
+        Logger.setLogLevel(level);
23 28
     }
29
+};
24 30
 
25
-}
26 31
 
27 32
 //Setups the promise object.
28 33
 window.Promise = window.Promise || require("es6-promise").polyfill();

+ 13
- 2
doc/API.md View File

@@ -41,6 +41,11 @@ The ```options``` parameter is JS object with the following properties:
41 41
 
42 42
 * ```JitsiMeetJS.JitsiConnection``` - the ```JitsiConnection``` constructor. You can use that to create new server connection.
43 43
 
44
+* ```JitsiMeetJS.setLogLevel``` - changes the log level for the library. For example to have only error messages you should do:
45
+```
46
+JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
47
+```
48
+
44 49
 * ```JitsiMeetJS.events``` - JS object that contains all events used by the API. You will need that JS object when you try to subscribe for connection or conference events.
45 50
     We have two event types - connection and conference. You can access the events with the following code ```JitsiMeetJS.events.<event_type>.<event_name>```.
46 51
     For example if you want to use the conference event that is fired when somebody leave conference you can use the following code - ```JitsiMeetJS.events.conference.USER_LEFT```.
@@ -77,7 +82,13 @@ The ```options``` parameter is JS object with the following properties:
77 82
         - PASSWORD_REQUIRED - passed when the connection to the server failed. You should try to authenticate with password.
78 83
         - CONNECTION_ERROR - indicates connection failures.
79 84
         - OTHER_ERROR - all other errors
80
-
85
+* ```JitsiMeetJS.logLevels``` - object with the log levels:
86
+    1. TRACE
87
+    2. DEBUG
88
+    3. INFO
89
+    4. LOG
90
+    5. WARN
91
+    6. ERROR
81 92
 
82 93
 JitsiConnection
83 94
 ------------
@@ -108,7 +119,7 @@ This objects represents the server connection. You can create new ```JitsiConnec
108 119
         1. devices - array with the devices - "video" and "audio" that will be passed to GUM. If that property is not set GUM will try to get all available devices.
109 120
         2. resolution - the prefered resolution for the local video.
110 121
         3. openSctp - boolean property. Enables/disables datachannel support. **NOTE: we recommend to set that option to true**
111
-        4. disableAudioLevels - boolean property. Enables/disables audio levels. 
122
+        4. disableAudioLevels - boolean property. Enables/disables audio levels.
112 123
 
113 124
 5. addEventListener(event, listener) - Subscribes the passed listener to the event.
114 125
     - event - one of the events from ```JitsiMeetJS.events.connection``` object.

+ 3
- 0
doc/example/example.js View File

@@ -120,7 +120,10 @@ function unload() {
120 120
 $(window).bind('beforeunload', unload);
121 121
 $(window).bind('unload', unload);
122 122
 
123
+JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
124
+
123 125
 JitsiMeetJS.init();
126
+
124 127
 var connection = new JitsiMeetJS.JitsiConnection(null, null, options);
125 128
 
126 129
 var room = null;

+ 633
- 297
lib-jitsi-meet.js
File diff suppressed because it is too large
View File


+ 13
- 11
modules/RTC/DataChannels.js View File

@@ -2,6 +2,8 @@
2 2
 
3 3
 // cache datachannels to avoid garbage collection
4 4
 // https://code.google.com/p/chromium/issues/detail?id=405545
5
+
6
+var logger = require("jitsi-meet-logger").getLogger(__filename);
5 7
 var RTCEvents = require("../../service/RTC/RTCEvents");
6 8
 
7 9
 
@@ -35,7 +37,7 @@ function DataChannels(peerConnection, emitter) {
35 37
      dataChannel.onmessage = function (event)
36 38
      {
37 39
      var msgData = event.data;
38
-     console.info("Got My Data Channel Message:", msgData, dataChannel);
40
+     logger.info("Got My Data Channel Message:", msgData, dataChannel);
39 41
      };*/
40 42
 };
41 43
 
@@ -50,7 +52,7 @@ DataChannels.prototype.onDataChannel = function (event) {
50 52
     var self = this;
51 53
 
52 54
     dataChannel.onopen = function () {
53
-        console.info("Data channel opened by the Videobridge!", dataChannel);
55
+        logger.info("Data channel opened by the Videobridge!", dataChannel);
54 56
 
55 57
         // Code sample for sending string and/or binary data
56 58
         // Sends String message to the bridge
@@ -62,7 +64,7 @@ DataChannels.prototype.onDataChannel = function (event) {
62 64
     };
63 65
 
64 66
     dataChannel.onerror = function (error) {
65
-        console.error("Data Channel Error:", error, dataChannel);
67
+        logger.error("Data Channel Error:", error, dataChannel);
66 68
     };
67 69
 
68 70
     dataChannel.onmessage = function (event) {
@@ -74,7 +76,7 @@ DataChannels.prototype.onDataChannel = function (event) {
74 76
             obj = JSON.parse(data);
75 77
         }
76 78
         catch (e) {
77
-            console.error(
79
+            logger.error(
78 80
                 "Failed to parse data channel message as JSON: ",
79 81
                 data,
80 82
                 dataChannel);
@@ -86,7 +88,7 @@ DataChannels.prototype.onDataChannel = function (event) {
86 88
                 // Endpoint ID from the Videobridge.
87 89
                 var dominantSpeakerEndpoint = obj.dominantSpeakerEndpoint;
88 90
 
89
-                console.info(
91
+                logger.info(
90 92
                     "Data channel new dominant speaker event: ",
91 93
                     dominantSpeakerEndpoint);
92 94
                 self.eventEmitter.emit(RTCEvents.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
@@ -122,20 +124,20 @@ DataChannels.prototype.onDataChannel = function (event) {
122 124
                 // endpoint IDs.
123 125
                 var endpointsEnteringLastN = obj.endpointsEnteringLastN;
124 126
 
125
-                console.log(
127
+                logger.log(
126 128
                     "Data channel new last-n event: ",
127 129
                     lastNEndpoints, endpointsEnteringLastN, obj);
128 130
                 this.eventEmitter.emit(RTCEvents.LASTN_ENDPOINT_CHANGED,
129 131
                     lastNEndpoints, endpointsEnteringLastN, obj);
130 132
             }
131 133
             else {
132
-                console.debug("Data channel JSON-formatted message: ", obj);
134
+                logger.debug("Data channel JSON-formatted message: ", obj);
133 135
             }
134 136
         }
135 137
     };
136 138
 
137 139
     dataChannel.onclose = function () {
138
-        console.info("The Data Channel closed", dataChannel);
140
+        logger.info("The Data Channel closed", dataChannel);
139 141
         var idx = self._dataChannels.indexOf(dataChannel);
140 142
         if (idx > -1)
141 143
             self._dataChannels = self._dataChannels.splice(idx, 1);
@@ -144,11 +146,11 @@ DataChannels.prototype.onDataChannel = function (event) {
144 146
 };
145 147
 
146 148
 DataChannels.prototype.handleSelectedEndpointEvent = function (userResource) {
147
-    console.log('selected endpoint changed: ', userResource);
149
+    logger.log('selected endpoint changed: ', userResource);
148 150
     if (this._dataChannels && this._dataChannels.length != 0) {
149 151
         this._dataChannels.some(function (dataChannel) {
150 152
             if (dataChannel.readyState == 'open') {
151
-                console.log('sending selected endpoint changed ' +
153
+                logger.log('sending selected endpoint changed ' +
152 154
                     'notification to the bridge: ', userResource);
153 155
                 dataChannel.send(JSON.stringify({
154 156
                     'colibriClass': 'SelectedEndpointChangedEvent',
@@ -164,7 +166,7 @@ DataChannels.prototype.handleSelectedEndpointEvent = function (userResource) {
164 166
 }
165 167
 
166 168
 DataChannels.prototype.handlePinnedEndpointEvent = function (userResource) {
167
-    console.log('pinned endpoint changed: ', userResource);
169
+    logger.log('pinned endpoint changed: ', userResource);
168 170
     if (this._dataChannels && this._dataChannels.length != 0) {
169 171
         this._dataChannels.some(function (dataChannel) {
170 172
             if (dataChannel.readyState == 'open') {

+ 18
- 16
modules/RTC/RTCUtils.js View File

@@ -1,4 +1,6 @@
1 1
 /* global config, require, attachMediaStream, getUserMedia */
2
+
3
+var logger = require("jitsi-meet-logger").getLogger(__filename);
2 4
 var RTCBrowserType = require("./RTCBrowserType");
3 5
 var Resolutions = require("../../service/RTC/Resolutions");
4 6
 var AdapterJS = require("./adapter.screenshare");
@@ -102,7 +104,7 @@ function getConstraints(um, resolution, bandwidth, fps, desktopStream) {
102 104
                 ]
103 105
             };
104 106
         } else {
105
-            console.error(
107
+            logger.error(
106 108
                 "'screen' WebRTC media source is supported only in Chrome" +
107 109
                 " and with Temasys plugin");
108 110
         }
@@ -188,7 +190,7 @@ var RTCUtils = {
188 190
                 RTCSessionDescription = mozRTCSessionDescription;
189 191
                 RTCIceCandidate = mozRTCIceCandidate;
190 192
             } else {
191
-                console.error(
193
+                logger.error(
192 194
                         "Firefox version too old: " + FFversion + ". Required >= 40.");
193 195
                 window.location.href = 'unsupported_browser.html';
194 196
                 return;
@@ -260,7 +262,7 @@ var RTCUtils = {
260 262
                 };
261 263
                 self.getVideoSrc = function (element) {
262 264
                     if (!element) {
263
-                        console.warn("Attempt to get video SRC of null element");
265
+                        logger.warn("Attempt to get video SRC of null element");
264 266
                         return null;
265 267
                     }
266 268
                     var children = element.children;
@@ -269,13 +271,13 @@ var RTCUtils = {
269 271
                             return children[i].value;
270 272
                         }
271 273
                     }
272
-                    //console.info(element.id + " SRC: " + src);
274
+                    //logger.info(element.id + " SRC: " + src);
273 275
                     return null;
274 276
                 };
275 277
                 self.setVideoSrc = function (element, src) {
276
-                    //console.info("Set video src: ", element, src);
278
+                    //logger.info("Set video src: ", element, src);
277 279
                     if (!src) {
278
-                        console.warn("Not attaching video stream, 'src' is null");
280
+                        logger.warn("Not attaching video stream, 'src' is null");
279 281
                         return;
280 282
                     }
281 283
                     AdapterJS.WebRTCPlugin.WaitForPluginReady();
@@ -288,7 +290,7 @@ var RTCUtils = {
288 290
             });
289 291
         } else {
290 292
             try {
291
-                console.error('Browser does not appear to be WebRTC-capable');
293
+                logger.error('Browser does not appear to be WebRTC-capable');
292 294
             } catch (e) {
293 295
             }
294 296
             return;
@@ -301,27 +303,27 @@ var RTCUtils = {
301 303
         var constraints = getConstraints(
302 304
             um, resolution, bandwidth, fps, desktopStream);
303 305
 
304
-        console.info("Get media constraints", constraints);
306
+        logger.info("Get media constraints", constraints);
305 307
 
306 308
         var self = this;
307 309
 
308 310
         try {
309 311
             this.getUserMedia(constraints,
310 312
                 function (stream) {
311
-                    console.log('onUserMediaSuccess');
313
+                    logger.log('onUserMediaSuccess');
312 314
                     self.setAvailableDevices(RTC, um, true);
313 315
                     success_callback(stream);
314 316
                 },
315 317
                 function (error) {
316 318
                     self.setAvailableDevices(RTC, um, false);
317
-                    console.warn('Failed to get access to local media. Error ',
319
+                    logger.warn('Failed to get access to local media. Error ',
318 320
                         error, constraints);
319 321
                     if (failure_callback) {
320 322
                         failure_callback(error, resolution);
321 323
                     }
322 324
                 });
323 325
         } catch (e) {
324
-            console.error('GUM failed: ', e);
326
+            logger.error('GUM failed: ', e);
325 327
             if (failure_callback) {
326 328
                 failure_callback(e);
327 329
             }
@@ -401,7 +403,7 @@ var RTCUtils = {
401 403
                             });
402 404
                         },
403 405
                         function (error, resolution) {
404
-                            console.error(
406
+                            logger.error(
405 407
                                 'failed to obtain video stream - stop', error);
406 408
                             self.errorCallback(error, resolve, RTC, resolution, dontCreateJitsiTracks);
407 409
                         },
@@ -416,7 +418,7 @@ var RTCUtils = {
416 418
                                 obtainVideo(audioStream);
417 419
                         },
418 420
                         function (error) {
419
-                            console.error(
421
+                            logger.error(
420 422
                                 'failed to obtain audio stream - stop', error);
421 423
                             self.errorCallback(error, resolve, RTC, null, dontCreateJitsiTracks);
422 424
                         }
@@ -454,7 +456,7 @@ var RTCUtils = {
454 456
         // If this is FF or IE, the stream parameter is *not* a MediaStream object,
455 457
         // it's an object with two properties: audioStream, videoStream.
456 458
         if (stream && stream.getAudioTracks && stream.getVideoTracks)
457
-            console.log('got', stream, stream.getAudioTracks().length,
459
+            logger.log('got', stream, stream.getAudioTracks().length,
458 460
                 stream.getVideoTracks().length);
459 461
         return this.handleLocalStream(RTC, stream, usageOptions, resolution);
460 462
     },
@@ -471,7 +473,7 @@ var RTCUtils = {
471 473
      */
472 474
     errorCallback: function (error, resolve, RTC, currentResolution, dontCreateJitsiTracks) {
473 475
         var self = this;
474
-        console.error('failed to obtain audio/video stream - trying audio only', error);
476
+        logger.error('failed to obtain audio/video stream - trying audio only', error);
475 477
         var resolution = getPreviousResolution(currentResolution);
476 478
         if (typeof error == "object" && error.constraintName && error.name
477 479
             && (error.name == "ConstraintNotSatisfiedError" ||
@@ -496,7 +498,7 @@ var RTCUtils = {
496 498
                     resolve(dontCreateJitsiTracks? streams: RTC.createLocalStreams(streams));
497 499
                 },
498 500
                 function (error) {
499
-                    console.error('failed to obtain audio/video stream - stop',
501
+                    logger.error('failed to obtain audio/video stream - stop',
500 502
                         error);
501 503
                     var streams = self.successCallback(RTC, null);
502 504
                     resolve(dontCreateJitsiTracks? streams: RTC.createLocalStreams(streams));

+ 4
- 3
modules/RTC/adapter.screenshare.js View File

@@ -1,4 +1,5 @@
1 1
 /*! adapterjs - v0.12.0 - 2015-09-04 */
2
+var console = require("jitsi-meet-logger").getLogger(__filename);
2 3
 
3 4
 // Adapter's interface.
4 5
 var AdapterJS = AdapterJS || {};
@@ -359,11 +360,11 @@ AdapterJS.renderNotificationBar = function (text, buttonText, buttonLink, openNe
359 360
             clearInterval(pluginInstallInterval);
360 361
             AdapterJS.WebRTCPlugin.defineWebRTCInterface();
361 362
           },
362
-          function() { 
363
+          function() {
363 364
             // still no plugin detected, nothing to do
364 365
           });
365 366
       } , 500);
366
-    });   
367
+    });
367 368
 
368 369
     // On click on Cancel
369 370
     AdapterJS.addEvent(c.document.getElementById('cancel'), 'click', function(e) {
@@ -1087,7 +1088,7 @@ if (navigator.mozGetUserMedia) {
1087 1088
           newElement.onclick(arg);
1088 1089
         };
1089 1090
       }
1090
-      
1091
+
1091 1092
       return newElement;
1092 1093
     };
1093 1094
 

+ 19
- 17
modules/desktopsharing/desktopsharing.js View File

@@ -31,6 +31,8 @@ var extInstalled = false;
31 31
  */
32 32
 var extUpdateRequired = false;
33 33
 
34
+
35
+var logger = require("jitsi-meet-logger").getLogger(__filename);
34 36
 var AdapterJS = require("../RTC/adapter.screenshare");
35 37
 
36 38
 var EventEmitter = require("events");
@@ -107,7 +109,7 @@ function isUpdateRequired(minVersion, extVersion)
107 109
     }
108 110
     catch (e)
109 111
     {
110
-        console.error("Failed to parse extension version", e);
112
+        logger.error("Failed to parse extension version", e);
111 113
         APP.UI.messageHandler.showError("dialog.error",
112 114
             "dialog.detectext");
113 115
         return true;
@@ -126,14 +128,14 @@ function checkChromeExtInstalled(callback) {
126 128
         function (response) {
127 129
             if (!response || !response.version) {
128 130
                 // Communication failure - assume that no endpoint exists
129
-                console.warn(
131
+                logger.warn(
130 132
                     "Extension not installed?: ", chrome.runtime.lastError);
131 133
                 callback(false, false);
132 134
                 return;
133 135
             }
134 136
             // Check installed extension version
135 137
             var extVersion = response.version;
136
-            console.log('Extension version is: ' + extVersion);
138
+            logger.log('Extension version is: ' + extVersion);
137 139
             var updateRequired
138 140
                 = isUpdateRequired(config.minChromeExtVersion, extVersion);
139 141
             callback(!updateRequired, updateRequired);
@@ -152,7 +154,7 @@ function doGetStreamFromExtension(streamCallback, failCallback) {
152 154
                 failCallback(chrome.runtime.lastError);
153 155
                 return;
154 156
             }
155
-            console.log("Response from extension: " + response);
157
+            logger.log("Response from extension: " + response);
156 158
             if (response.streamId) {
157 159
                 APP.RTC.getUserMediaWithConstraints(
158 160
                     ['desktop'],
@@ -185,7 +187,7 @@ function obtainScreenFromExtension(streamCallback, failCallback) {
185 187
         chrome.webstore.install(
186 188
             getWebStoreInstallUrl(),
187 189
             function (arg) {
188
-                console.log("Extension installed successfully", arg);
190
+                logger.log("Extension installed successfully", arg);
189 191
                 extInstalled = true;
190 192
                 // We need to give a moment for the endpoint to become available
191 193
                 window.setTimeout(function () {
@@ -193,7 +195,7 @@ function obtainScreenFromExtension(streamCallback, failCallback) {
193 195
                 }, 500);
194 196
             },
195 197
             function (arg) {
196
-                console.log("Failed to install the extension", arg);
198
+                logger.log("Failed to install the extension", arg);
197 199
                 failCallback(arg);
198 200
                 APP.UI.messageHandler.showError("dialog.error",
199 201
                     "dialog.failtoinstall");
@@ -218,31 +220,31 @@ function setDesktopSharing(method) {
218 220
     // care about 'method' parameter
219 221
     if (RTCBrowserType.isTemasysPluginUsed()) {
220 222
         if (!AdapterJS.WebRTCPlugin.plugin.HasScreensharingFeature) {
221
-            console.info("Screensharing not supported by this plugin version");
223
+            logger.info("Screensharing not supported by this plugin version");
222 224
         } else if (!AdapterJS.WebRTCPlugin.plugin.isScreensharingAvailable) {
223
-            console.info(
225
+            logger.info(
224 226
             "Screensharing not available with Temasys plugin on this site");
225 227
         } else {
226 228
             obtainDesktopStream = obtainWebRTCScreen;
227
-            console.info("Using Temasys plugin for desktop sharing");
229
+            logger.info("Using Temasys plugin for desktop sharing");
228 230
         }
229 231
     } else if (RTCBrowserType.isChrome()) {
230 232
         if (method == "ext") {
231 233
             if (RTCBrowserType.getChromeVersion() >= 34) {
232 234
                 obtainDesktopStream = obtainScreenFromExtension;
233
-                console.info("Using Chrome extension for desktop sharing");
235
+                logger.info("Using Chrome extension for desktop sharing");
234 236
                 initChromeExtension();
235 237
             } else {
236
-                console.info("Chrome extension not supported until ver 34");
238
+                logger.info("Chrome extension not supported until ver 34");
237 239
             }
238 240
         } else if (method == "webrtc") {
239 241
             obtainDesktopStream = obtainWebRTCScreen;
240
-            console.info("Using Chrome WebRTC for desktop sharing");
242
+            logger.info("Using Chrome WebRTC for desktop sharing");
241 243
         }
242 244
     }
243 245
 
244 246
     if (!obtainDesktopStream) {
245
-        console.info("Desktop sharing disabled");
247
+        logger.info("Desktop sharing disabled");
246 248
     }
247 249
 }
248 250
 
@@ -263,21 +265,21 @@ function initChromeExtension() {
263 265
     checkChromeExtInstalled(function (installed, updateRequired) {
264 266
         extInstalled = installed;
265 267
         extUpdateRequired = updateRequired;
266
-        console.info(
268
+        logger.info(
267 269
             "Chrome extension installed: " + extInstalled +
268 270
             " updateRequired: " + extUpdateRequired);
269 271
     });
270 272
 }
271 273
 
272 274
 function getVideoStreamFailed(error) {
273
-    console.error("Failed to obtain the stream to switch to", error);
275
+    logger.error("Failed to obtain the stream to switch to", error);
274 276
     switchInProgress = false;
275 277
     isUsingScreenStream = false;
276 278
     newStreamCreated(null);
277 279
 }
278 280
 
279 281
 function getDesktopStreamFailed(error) {
280
-    console.error("Failed to obtain the stream to switch to", error);
282
+    logger.error("Failed to obtain the stream to switch to", error);
281 283
     switchInProgress = false;
282 284
 }
283 285
 
@@ -343,7 +345,7 @@ module.exports = {
343 345
      */
344 346
     toggleScreenSharing: function () {
345 347
         if (switchInProgress || !obtainDesktopStream) {
346
-            console.warn("Switch in progress or no method defined");
348
+            logger.warn("Switch in progress or no method defined");
347 349
             return;
348 350
         }
349 351
         switchInProgress = true;

+ 5
- 3
modules/settings/Settings.js View File

@@ -1,8 +1,10 @@
1
+
2
+var logger = require("jitsi-meet-logger").getLogger(__filename);
1 3
 function supportsLocalStorage() {
2 4
     try {
3 5
         return 'localStorage' in window && window.localStorage !== null;
4 6
     } catch (e) {
5
-        console.log("localstorage is not supported");
7
+        logger.log("localstorage is not supported");
6 8
         return false;
7 9
     }
8 10
 }
@@ -29,7 +31,7 @@ function Settings(conferenceID) {
29 31
             this.confSettings = JSON.parse(window.localStorage.getItem(conferenceID));
30 32
         if(!this.confSettings.jitsiMeetId) {
31 33
             this.confSettings.jitsiMeetId = generateUniqueId();
32
-            console.log("generated id",
34
+            logger.log("generated id",
33 35
                 this.confSettings.jitsiMeetId);
34 36
             this.save();
35 37
         }
@@ -38,7 +40,7 @@ function Settings(conferenceID) {
38 40
         this.displayName = this.confSettings.displayname || '';
39 41
         this.language = this.confSettings.language;
40 42
     } else {
41
-        console.log("local storage is not supported");
43
+        logger.log("local storage is not supported");
42 44
         this.userId = generateUniqueId();
43 45
     }
44 46
 }

+ 4
- 2
modules/statistics/CallStats.js View File

@@ -1,10 +1,12 @@
1 1
 /* global config, $, APP, Strophe, callstats */
2
+var logger = require("jitsi-meet-logger").getLogger(__filename);
3
+
2 4
 var jsSHA = require('jssha');
3 5
 var io = require('socket.io-client');
4 6
 var callStats = null;
5 7
 
6 8
 function initCallback (err, msg) {
7
-    console.log("Initializing Status: err="+err+" msg="+msg);
9
+    logger.log("Initializing Status: err="+err+" msg="+msg);
8 10
 }
9 11
 
10 12
 var CallStats = {
@@ -41,7 +43,7 @@ var CallStats = {
41 43
     pcCallback: function (err, msg) {
42 44
         if (!callStats)
43 45
             return;
44
-        console.log("Monitoring status: "+ err + " msg: " + msg);
46
+        logger.log("Monitoring status: "+ err + " msg: " + msg);
45 47
         callStats.sendFabricEvent(this.peerconnection,
46 48
             callStats.fabricEvent.fabricSetup, this.confID);
47 49
     },

+ 11
- 9
modules/statistics/RTPStatsCollector.js View File

@@ -1,5 +1,7 @@
1 1
 /* global require, ssrc2jid */
2 2
 /* jshint -W117 */
3
+
4
+var logger = require("jitsi-meet-logger").getLogger(__filename);
3 5
 var RTCBrowserType = require("../RTC/RTCBrowserType");
4 6
 
5 7
 /* Whether we support the browser we are running into for logging statistics */
@@ -295,7 +297,7 @@ StatsCollector.prototype.stop = function () {
295 297
  */
296 298
 StatsCollector.prototype.errorCallback = function (error)
297 299
 {
298
-    console.error("Get stats error", error);
300
+    logger.error("Get stats error", error);
299 301
     this.stop();
300 302
 };
301 303
 
@@ -318,7 +320,7 @@ StatsCollector.prototype.start = function ()
318 320
                     else {
319 321
                         results = report.result();
320 322
                     }
321
-                    //console.error("Got interval report", results);
323
+                    //logger.error("Got interval report", results);
322 324
                     self.currentAudioLevelsReport = results;
323 325
                     self.processAudioLevelReport();
324 326
                     self.baselineAudioLevelsReport =
@@ -346,13 +348,13 @@ StatsCollector.prototype.start = function ()
346 348
 //                            //chrome
347 349
 //                            results = report.result();
348 350
 //                        }
349
-//                        //console.error("Got interval report", results);
351
+//                        //logger.error("Got interval report", results);
350 352
 //                        self.currentStatsReport = results;
351 353
 //                        try {
352 354
 //                            self.processStatsReport();
353 355
 //                        }
354 356
 //                        catch (e) {
355
-//                            console.error("Unsupported key:" + e, e);
357
+//                            logger.error("Unsupported key:" + e, e);
356 358
 //                        }
357 359
 //
358 360
 //                        self.baselineStatsReport = self.currentStatsReport;
@@ -498,7 +500,7 @@ StatsCollector.prototype.processStatsReport = function () {
498 500
 
499 501
         var before = this.baselineStatsReport[idx];
500 502
         if (!before) {
501
-            console.warn(getStatValue(now, 'ssrc') + ' not enough data');
503
+            logger.warn(getStatValue(now, 'ssrc') + ' not enough data');
502 504
             continue;
503 505
         }
504 506
 
@@ -521,7 +523,7 @@ StatsCollector.prototype.processStatsReport = function () {
521 523
             key = 'packetsSent';
522 524
             if (!getStatValue(now, key))
523 525
             {
524
-                console.warn("No packetsReceived nor packetSent stat found");
526
+                logger.warn("No packetsReceived nor packetSent stat found");
525 527
                 continue;
526 528
             }
527 529
         }
@@ -692,14 +694,14 @@ StatsCollector.prototype.processAudioLevelReport = function () {
692 694
 
693 695
         var before = this.baselineAudioLevelsReport[idx];
694 696
         if (!before) {
695
-            console.warn(getStatValue(now, 'ssrc') + ' not enough data');
697
+            logger.warn(getStatValue(now, 'ssrc') + ' not enough data');
696 698
             continue;
697 699
         }
698 700
 
699 701
         var ssrc = getStatValue(now, 'ssrc');
700 702
         if (!ssrc) {
701 703
             if((Date.now() - now.timestamp) < 3000)
702
-                console.warn("No ssrc: ");
704
+                logger.warn("No ssrc: ");
703 705
             continue;
704 706
         }
705 707
 
@@ -718,7 +720,7 @@ StatsCollector.prototype.processAudioLevelReport = function () {
718 720
                 audioLevel = getStatValue(now, 'audioOutputLevel');
719 721
         }
720 722
         catch(e) {/*not supported*/
721
-            console.warn("Audio Levels are not available in the statistics.");
723
+            logger.warn("Audio Levels are not available in the statistics.");
722 724
             clearInterval(this.audioLevelsIntervalId);
723 725
             return;
724 726
         }

+ 20
- 18
modules/xmpp/ChatRoom.js View File

@@ -1,3 +1,5 @@
1
+
2
+var logger = require("jitsi-meet-logger").getLogger(__filename);
1 3
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
2 4
 var Moderator = require("./moderator");
3 5
 var EventEmitter = require("events");
@@ -60,7 +62,7 @@ function ChatRoom(connection, jid, password, XMPP, options) {
60 62
     this.roomjid = Strophe.getBareJidFromJid(jid);
61 63
     this.myroomjid = jid;
62 64
     this.password = password;
63
-    console.info("Joined MUC as " + this.myroomjid);
65
+    logger.info("Joined MUC as " + this.myroomjid);
64 66
     this.members = {};
65 67
     this.presMap = {};
66 68
     this.presHandlers = {};
@@ -128,7 +130,7 @@ ChatRoom.prototype.sendPresence = function (tokenPassword) {
128 130
 
129 131
 
130 132
 ChatRoom.prototype.doLeave = function () {
131
-    console.log("do leave", this.myroomjid);
133
+    logger.log("do leave", this.myroomjid);
132 134
     var pres = $pres({to: this.myroomjid, type: 'unavailable' });
133 135
     this.presMap.length = 0;
134 136
     this.connection.send(pres);
@@ -150,7 +152,7 @@ ChatRoom.prototype.createNonAnonymousRoom = function () {
150 152
                 '>query>x[xmlns="jabber:x:data"]' +
151 153
                 '>field[var="muc#roomconfig_whois"]').length) {
152 154
 
153
-            console.error('non-anonymous rooms not supported');
155
+            logger.error('non-anonymous rooms not supported');
154 156
             return;
155 157
         }
156 158
 
@@ -169,7 +171,7 @@ ChatRoom.prototype.createNonAnonymousRoom = function () {
169 171
         self.connection.sendIQ(formSubmit);
170 172
 
171 173
     }, function (error) {
172
-        console.error("Error getting room configuration form");
174
+        logger.error("Error getting room configuration form");
173 175
     });
174 176
 };
175 177
 
@@ -209,7 +211,7 @@ ChatRoom.prototype.onPresence = function (pres) {
209 211
                     if (displayName && displayName.length > 0) {
210 212
                         this.eventEmitter.emit(XMPPEvents.DISPLAY_NAME_CHANGED, from, displayName);
211 213
                     }
212
-                    console.info("Display name: " + displayName, pres);
214
+                    logger.info("Display name: " + displayName, pres);
213 215
                 }
214 216
                 break;
215 217
             case "userId":
@@ -246,10 +248,10 @@ ChatRoom.prototype.onPresence = function (pres) {
246 248
     } else if (this.members[from] === undefined) {
247 249
         // new participant
248 250
         this.members[from] = member;
249
-        console.log('entered', from, member);
251
+        logger.log('entered', from, member);
250 252
         if (member.isFocus) {
251 253
             this.focusMucJid = from;
252
-            console.info("Ignore focus: " + from + ", real JID: " + member.jid);
254
+            logger.info("Ignore focus: " + from + ", real JID: " + member.jid);
253 255
         }
254 256
         else {
255 257
             this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_JOINED, from, member.id || member.email, member.nick);
@@ -295,7 +297,7 @@ ChatRoom.prototype.setSubject = function (subject) {
295 297
     var msg = $msg({to: this.roomjid, type: 'groupchat'});
296 298
     msg.c('subject', subject);
297 299
     this.connection.send(msg);
298
-    console.log("topic changed to " + subject);
300
+    logger.log("topic changed to " + subject);
299 301
 };
300 302
 
301 303
 
@@ -366,7 +368,7 @@ ChatRoom.prototype.onMessage = function (msg, from) {
366 368
         var subjectText = subject.text();
367 369
         if (subjectText || subjectText == "") {
368 370
             this.eventEmitter.emit(XMPPEvents.SUBJECT_CHANGED, subjectText);
369
-            console.log("Subject is changed to " + subjectText);
371
+            logger.log("Subject is changed to " + subjectText);
370 372
         }
371 373
     }
372 374
 
@@ -385,7 +387,7 @@ ChatRoom.prototype.onMessage = function (msg, from) {
385 387
     }
386 388
 
387 389
     if (txt) {
388
-        console.log('chat', nick, txt);
390
+        logger.log('chat', nick, txt);
389 391
         this.eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
390 392
             from, nick, txt, this.myroomjid, stamp);
391 393
     }
@@ -393,7 +395,7 @@ ChatRoom.prototype.onMessage = function (msg, from) {
393 395
 
394 396
 ChatRoom.prototype.onPresenceError = function (pres, from) {
395 397
     if ($(pres).find('>error[type="auth"]>not-authorized[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
396
-        console.log('on password required', from);
398
+        logger.log('on password required', from);
397 399
         this.eventEmitter.emit(XMPPEvents.PASSWORD_REQUIRED);
398 400
     } else if ($(pres).find(
399 401
         '>error[type="cancel"]>not-allowed[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
@@ -406,11 +408,11 @@ ChatRoom.prototype.onPresenceError = function (pres, from) {
406 408
             this.eventEmitter.emit(XMPPEvents.ROOM_JOIN_ERROR, pres);
407 409
 
408 410
         } else {
409
-            console.warn('onPresError ', pres);
411
+            logger.warn('onPresError ', pres);
410 412
             this.eventEmitter.emit(XMPPEvents.ROOM_CONNECT_ERROR, pres);
411 413
         }
412 414
     } else {
413
-        console.warn('onPresError ', pres);
415
+        logger.warn('onPresError ', pres);
414 416
         this.eventEmitter.emit(XMPPEvents.ROOM_CONNECT_ERROR, pres);
415 417
     }
416 418
 };
@@ -424,10 +426,10 @@ ChatRoom.prototype.kick = function (jid) {
424 426
     this.connection.sendIQ(
425 427
         kickIQ,
426 428
         function (result) {
427
-            console.log('Kick participant with jid: ', jid, result);
429
+            logger.log('Kick participant with jid: ', jid, result);
428 430
         },
429 431
         function (error) {
430
-            console.log('Kick participant error: ', error);
432
+            logger.log('Kick participant error: ', error);
431 433
         });
432 434
 };
433 435
 
@@ -503,7 +505,7 @@ ChatRoom.prototype.switchStreams = function (stream, oldStream, callback, isAudi
503 505
         this.session.switchStreams(stream, oldStream, callback, isAudio);
504 506
     } else {
505 507
         // We are done immediately
506
-        console.warn("No conference handler or conference not started yet");
508
+        logger.warn("No conference handler or conference not started yet");
507 509
         callback();
508 510
     }
509 511
 };
@@ -514,7 +516,7 @@ ChatRoom.prototype.addStream = function (stream, callback) {
514 516
         this.session.addStream(stream, callback);
515 517
     } else {
516 518
         // We are done immediately
517
-        console.warn("No conference handler or conference not started yet");
519
+        logger.warn("No conference handler or conference not started yet");
518 520
         callback();
519 521
     }
520 522
 }
@@ -541,7 +543,7 @@ ChatRoom.prototype.setVideoMute = function (mute, callback, options) {
541 543
 ChatRoom.prototype.setAudioMute = function (mute, callback) {
542 544
     //This will be for remote streams only
543 545
 //    if (this.forceMuted && !mute) {
544
-//        console.info("Asking focus for unmute");
546
+//        logger.info("Asking focus for unmute");
545 547
 //        this.connection.moderate.setMute(this.connection.emuc.myroomjid, mute);
546 548
 //        // FIXME: wait for result before resetting muted status
547 549
 //        this.forceMuted = false;

+ 3
- 1
modules/xmpp/JingleSession.js View File

@@ -3,6 +3,8 @@
3 3
  * have different implementations depending on the underlying interface used
4 4
  * (i.e. WebRTC and ORTC) and here we hold the code common to all of them.
5 5
  */
6
+var logger = require("jitsi-meet-logger").getLogger(__filename);
7
+
6 8
 function JingleSession(me, sid, connection, service, eventEmitter) {
7 9
     /**
8 10
      * Our JID.
@@ -64,7 +66,7 @@ JingleSession.prototype.initialize = function(peerjid, isInitiator,
64 66
     this.ice_config = ice_config;
65 67
 
66 68
     if (this.state !== null) {
67
-        console.error('attempt to initiate on session ' + this.sid +
69
+        logger.error('attempt to initiate on session ' + this.sid +
68 70
         'in state ' + this.state);
69 71
         return;
70 72
     }

+ 82
- 80
modules/xmpp/JingleSessionPC.js View File

@@ -1,4 +1,6 @@
1 1
 /* jshint -W117 */
2
+
3
+var logger = require("jitsi-meet-logger").getLogger(__filename);
2 4
 var JingleSession = require("./JingleSession");
3 5
 var TraceablePeerConnection = require("./TraceablePeerConnection");
4 6
 var SDPDiffer = require("./SDPDiffer");
@@ -96,14 +98,14 @@ JingleSessionPC.prototype.doInitialize = function () {
96 98
     };
97 99
     this.peerconnection.onaddstream = function (event) {
98 100
         if (event.stream.id !== 'default') {
99
-            console.log("REMOTE STREAM ADDED: ", event.stream , event.stream.id);
101
+            logger.log("REMOTE STREAM ADDED: ", event.stream , event.stream.id);
100 102
             self.remoteStreamAdded(event);
101 103
         } else {
102 104
             // This is a recvonly stream. Clients that implement Unified Plan,
103 105
             // such as Firefox use recvonly "streams/channels/tracks" for
104 106
             // receiving remote stream/tracks, as opposed to Plan B where there
105 107
             // are only 3 channels: audio, video and data.
106
-            console.log("RECVONLY REMOTE STREAM IGNORED: " + event.stream + " - " + event.stream.id);
108
+            logger.log("RECVONLY REMOTE STREAM IGNORED: " + event.stream + " - " + event.stream.id);
107 109
         }
108 110
     };
109 111
     this.peerconnection.onremovestream = function (event) {
@@ -216,7 +218,7 @@ JingleSessionPC.prototype.accept = function () {
216 218
     if (!pranswer || pranswer.type != 'pranswer') {
217 219
         return;
218 220
     }
219
-    console.log('going from pranswer to answer');
221
+    logger.log('going from pranswer to answer');
220 222
     if (this.usetrickle) {
221 223
         // remove candidates already sent from session-accept
222 224
         var lines = SDPUtil.find_lines(pranswer.sdp, 'a=candidate:');
@@ -249,7 +251,7 @@ JingleSessionPC.prototype.accept = function () {
249 251
     var self = this;
250 252
     this.peerconnection.setLocalDescription(new RTCSessionDescription({type: 'answer', sdp: sdp}),
251 253
         function () {
252
-            //console.log('setLocalDescription success');
254
+            //logger.log('setLocalDescription success');
253 255
             self.setLocalDescription();
254 256
 
255 257
             SSRCReplacement.processSessionInit(accept);
@@ -271,7 +273,7 @@ JingleSessionPC.prototype.accept = function () {
271 273
                 10000);
272 274
         },
273 275
         function (e) {
274
-            console.error('setLocalDescription failed', e);
276
+            logger.error('setLocalDescription failed', e);
275 277
             self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
276 278
         }
277 279
     );
@@ -297,7 +299,7 @@ JingleSessionPC.prototype.sendIceCandidate = function (candidate) {
297 299
         var ice = SDPUtil.iceparams(this.localSDP.media[candidate.sdpMLineIndex], this.localSDP.session);
298 300
         var jcand = SDPUtil.candidateToJingle(candidate.candidate);
299 301
         if (!(ice && jcand)) {
300
-            console.error('failed to get ice && jcand');
302
+            logger.error('failed to get ice && jcand');
301 303
             return;
302 304
         }
303 305
         ice.xmlns = 'urn:xmpp:jingle:transports:ice-udp:1';
@@ -326,9 +328,9 @@ JingleSessionPC.prototype.sendIceCandidate = function (candidate) {
326 328
             }
327 329
         }
328 330
     } else {
329
-        //console.log('sendIceCandidate: last candidate.');
331
+        //logger.log('sendIceCandidate: last candidate.');
330 332
         if (!this.usetrickle) {
331
-            //console.log('should send full offer now...');
333
+            //logger.log('should send full offer now...');
332 334
             //FIXME why do we generate session-accept in 3 different places ?
333 335
             var init = $iq({to: this.peerjid,
334 336
                 type: 'set'})
@@ -349,7 +351,7 @@ JingleSessionPC.prototype.sendIceCandidate = function (candidate) {
349 351
 
350 352
                 self.connection.sendIQ(init,
351 353
                     function () {
352
-                        //console.log('session initiate ack');
354
+                        //logger.log('session initiate ack');
353 355
                         var ack = {};
354 356
                         ack.source = 'offer';
355 357
                         $(document).trigger('ack.jingle', [self.sid, ack]);
@@ -369,8 +371,8 @@ JingleSessionPC.prototype.sendIceCandidate = function (candidate) {
369 371
             sendJingle();
370 372
         }
371 373
         this.lasticecandidate = true;
372
-        console.log('Have we encountered any srflx candidates? ' + this.hadstuncandidate);
373
-        console.log('Have we encountered any relay candidates? ' + this.hadturncandidate);
374
+        logger.log('Have we encountered any srflx candidates? ' + this.hadstuncandidate);
375
+        logger.log('Have we encountered any relay candidates? ' + this.hadturncandidate);
374 376
 
375 377
         if (!(this.hadstuncandidate || this.hadturncandidate) && this.peerconnection.signalingState != 'closed') {
376 378
             $(document).trigger('nostuncandidates.jingle', [this.sid]);
@@ -379,7 +381,7 @@ JingleSessionPC.prototype.sendIceCandidate = function (candidate) {
379 381
 };
380 382
 
381 383
 JingleSessionPC.prototype.sendIceCandidates = function (candidates) {
382
-    console.log('sendIceCandidates', candidates);
384
+    logger.log('sendIceCandidates', candidates);
383 385
     var cand = $iq({to: this.peerjid, type: 'set'})
384 386
         .c('jingle', {xmlns: 'urn:xmpp:jingle:1',
385 387
             action: 'transport-info',
@@ -414,7 +416,7 @@ JingleSessionPC.prototype.sendIceCandidates = function (candidates) {
414 416
         }
415 417
     }
416 418
     // might merge last-candidate notification into this, but it is called alot later. See webrtc issue #2340
417
-    //console.log('was this the last candidate', this.lasticecandidate);
419
+    //logger.log('was this the last candidate', this.lasticecandidate);
418 420
     this.connection.sendIQ(cand,
419 421
         function () {
420 422
             var ack = {};
@@ -434,13 +436,13 @@ JingleSessionPC.prototype.sendIceCandidates = function (candidates) {
434 436
 
435 437
 
436 438
 JingleSessionPC.prototype.sendOffer = function () {
437
-    //console.log('sendOffer...');
439
+    //logger.log('sendOffer...');
438 440
     var self = this;
439 441
     this.peerconnection.createOffer(function (sdp) {
440 442
             self.createdOffer(sdp);
441 443
         },
442 444
         function (e) {
443
-            console.error('createOffer failed', e);
445
+            logger.error('createOffer failed', e);
444 446
         },
445 447
         this.media_constraints
446 448
     );
@@ -448,7 +450,7 @@ JingleSessionPC.prototype.sendOffer = function () {
448 450
 
449 451
 // FIXME createdOffer is never used in jitsi-meet
450 452
 JingleSessionPC.prototype.createdOffer = function (sdp) {
451
-    //console.log('createdOffer', sdp);
453
+    //logger.log('createdOffer', sdp);
452 454
     var self = this;
453 455
     this.localSDP = new SDP(sdp.sdp);
454 456
     //this.localSDP.mangle();
@@ -492,10 +494,10 @@ JingleSessionPC.prototype.createdOffer = function (sdp) {
492 494
                 sendJingle();
493 495
             }
494 496
             self.setLocalDescription();
495
-            //console.log('setLocalDescription success');
497
+            //logger.log('setLocalDescription success');
496 498
         },
497 499
         function (e) {
498
-            console.error('setLocalDescription failed', e);
500
+            logger.error('setLocalDescription failed', e);
499 501
             self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
500 502
         }
501 503
     );
@@ -533,12 +535,12 @@ JingleSessionPC.prototype.getSsrcOwner = function (ssrc) {
533 535
 };
534 536
 
535 537
 JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
536
-    //console.log('setting remote description... ', desctype);
538
+    //logger.log('setting remote description... ', desctype);
537 539
     this.remoteSDP = new SDP('');
538 540
     this.remoteSDP.fromJingle(elem);
539 541
     this.readSsrcInfo($(elem).find(">content"));
540 542
     if (this.peerconnection.remoteDescription !== null) {
541
-        console.log('setRemoteDescription when remote description is not null, should be pranswer', this.peerconnection.remoteDescription);
543
+        logger.log('setRemoteDescription when remote description is not null, should be pranswer', this.peerconnection.remoteDescription);
542 544
         if (this.peerconnection.remoteDescription.type == 'pranswer') {
543 545
             var pranswer = new SDP(this.peerconnection.remoteDescription.sdp);
544 546
             for (var i = 0; i < pranswer.media.length; i++) {
@@ -547,12 +549,12 @@ JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
547 549
                     if (SDPUtil.find_line(pranswer.media[i], 'a=ice-ufrag:', pranswer.session)) {
548 550
                         this.remoteSDP.media[i] += SDPUtil.find_line(pranswer.media[i], 'a=ice-ufrag:', pranswer.session) + '\r\n';
549 551
                     } else {
550
-                        console.warn('no ice ufrag?');
552
+                        logger.warn('no ice ufrag?');
551 553
                     }
552 554
                     if (SDPUtil.find_line(pranswer.media[i], 'a=ice-pwd:', pranswer.session)) {
553 555
                         this.remoteSDP.media[i] += SDPUtil.find_line(pranswer.media[i], 'a=ice-pwd:', pranswer.session) + '\r\n';
554 556
                     } else {
555
-                        console.warn('no ice pwd?');
557
+                        logger.warn('no ice pwd?');
556 558
                     }
557 559
                 }
558 560
                 // copy over candidates
@@ -568,10 +570,10 @@ JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
568 570
 
569 571
     this.peerconnection.setRemoteDescription(remotedesc,
570 572
         function () {
571
-            //console.log('setRemoteDescription success');
573
+            //logger.log('setRemoteDescription success');
572 574
         },
573 575
         function (e) {
574
-            console.error('setRemoteDescription error', e);
576
+            logger.error('setRemoteDescription error', e);
575 577
             JingleSessionPC.onJingleFatalError(self, e);
576 578
         }
577 579
     );
@@ -583,7 +585,7 @@ JingleSessionPC.prototype.addIceCandidate = function (elem) {
583 585
         return;
584 586
     }
585 587
     if (!this.peerconnection.remoteDescription && this.peerconnection.signalingState == 'have-local-offer') {
586
-        console.log('trickle ice candidate arriving before session accept...');
588
+        logger.log('trickle ice candidate arriving before session accept...');
587 589
         // create a PRANSWER for setRemoteDescription
588 590
         if (!this.remoteSDP) {
589 591
             var cobbled = 'v=0\r\n' +
@@ -614,7 +616,7 @@ JingleSessionPC.prototype.addIceCandidate = function (elem) {
614 616
                         if (tmp.length) {
615 617
                             self.remoteSDP.media[i] += 'a=fingerprint:' + tmp.attr('hash') + ' ' + tmp.text() + '\r\n';
616 618
                         } else {
617
-                            console.log('no dtls fingerprint (webrtc issue #1718?)');
619
+                            logger.log('no dtls fingerprint (webrtc issue #1718?)');
618 620
                             self.remoteSDP.media[i] += 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:BAADBAADBAADBAADBAADBAADBAADBAADBAADBAAD\r\n';
619 621
                         }
620 622
                         break;
@@ -632,19 +634,19 @@ JingleSessionPC.prototype.addIceCandidate = function (elem) {
632 634
         }).length == this.remoteSDP.media.length;
633 635
 
634 636
         if (iscomplete) {
635
-            console.log('setting pranswer');
637
+            logger.log('setting pranswer');
636 638
             try {
637 639
                 this.peerconnection.setRemoteDescription(new RTCSessionDescription({type: 'pranswer', sdp: this.remoteSDP.raw }),
638 640
                     function() {
639 641
                     },
640 642
                     function(e) {
641
-                        console.log('setRemoteDescription pranswer failed', e.toString());
643
+                        logger.log('setRemoteDescription pranswer failed', e.toString());
642 644
                     });
643 645
             } catch (e) {
644
-                console.error('setting pranswer failed', e);
646
+                logger.error('setting pranswer failed', e);
645 647
             }
646 648
         } else {
647
-            //console.log('not yet setting pranswer');
649
+            //logger.log('not yet setting pranswer');
648 650
         }
649 651
     }
650 652
     // operate on each content element
@@ -679,21 +681,21 @@ JingleSessionPC.prototype.addIceCandidate = function (elem) {
679 681
             try {
680 682
                 self.peerconnection.addIceCandidate(candidate);
681 683
             } catch (e) {
682
-                console.error('addIceCandidate failed', e.toString(), line);
684
+                logger.error('addIceCandidate failed', e.toString(), line);
683 685
             }
684 686
         });
685 687
     });
686 688
 };
687 689
 
688 690
 JingleSessionPC.prototype.sendAnswer = function (provisional) {
689
-    //console.log('createAnswer', provisional);
691
+    //logger.log('createAnswer', provisional);
690 692
     var self = this;
691 693
     this.peerconnection.createAnswer(
692 694
         function (sdp) {
693 695
             self.createdAnswer(sdp, provisional);
694 696
         },
695 697
         function (e) {
696
-            console.error('createAnswer failed', e);
698
+            logger.error('createAnswer failed', e);
697 699
             self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
698 700
         },
699 701
         this.media_constraints
@@ -701,7 +703,7 @@ JingleSessionPC.prototype.sendAnswer = function (provisional) {
701 703
 };
702 704
 
703 705
 JingleSessionPC.prototype.createdAnswer = function (sdp, provisional) {
704
-    //console.log('createAnswer callback');
706
+    //logger.log('createAnswer callback');
705 707
     var self = this;
706 708
     this.localSDP = new SDP(sdp.sdp);
707 709
     //this.localSDP.mangle();
@@ -752,14 +754,14 @@ JingleSessionPC.prototype.createdAnswer = function (sdp, provisional) {
752 754
     this.peerconnection.setLocalDescription(sdp,
753 755
         function () {
754 756
 
755
-            //console.log('setLocalDescription success');
757
+            //logger.log('setLocalDescription success');
756 758
             if (self.usetrickle && !self.usepranswer) {
757 759
                 sendJingle();
758 760
             }
759 761
             self.setLocalDescription();
760 762
         },
761 763
         function (e) {
762
-            console.error('setLocalDescription failed', e);
764
+            logger.error('setLocalDescription failed', e);
763 765
             self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
764 766
         }
765 767
     );
@@ -818,7 +820,7 @@ JingleSessionPC.prototype.addSource = function (elem, fromJid) {
818 820
     // FIXME: dirty waiting
819 821
     if (!this.peerconnection.localDescription)
820 822
     {
821
-        console.warn("addSource - localDescription not ready yet")
823
+        logger.warn("addSource - localDescription not ready yet")
822 824
         setTimeout(function()
823 825
             {
824 826
                 self.addSource(elem, fromJid);
@@ -828,8 +830,8 @@ JingleSessionPC.prototype.addSource = function (elem, fromJid) {
828 830
         return;
829 831
     }
830 832
 
831
-    console.log('addssrc', new Date().getTime());
832
-    console.log('ice', this.peerconnection.iceConnectionState);
833
+    logger.log('addssrc', new Date().getTime());
834
+    logger.log('ice', this.peerconnection.iceConnectionState);
833 835
 
834 836
     this.readSsrcInfo(elem);
835 837
 
@@ -858,11 +860,11 @@ JingleSessionPC.prototype.addSource = function (elem, fromJid) {
858 860
                  * ColibriFocus.modifySources have to wait for stable state. In the meantime multiple
859 861
                  * addssrc are scheduled for update IQ. See
860 862
                  */
861
-                console.warn("Got add stream request for my own ssrc: "+ssrc);
863
+                logger.warn("Got add stream request for my own ssrc: "+ssrc);
862 864
                 return;
863 865
             }
864 866
             if (sdp.containsSSRC(ssrc)) {
865
-                console.warn("Source-add request for existing SSRC: " + ssrc);
867
+                logger.warn("Source-add request for existing SSRC: " + ssrc);
866 868
                 return;
867 869
             }
868 870
             $(this).find('>parameter').each(function () {
@@ -886,10 +888,10 @@ JingleSessionPC.prototype.addSource = function (elem, fromJid) {
886 888
         // When a source is added and if this is FF, a new channel is allocated
887 889
         // for receiving the added source. We need to diffuse the SSRC of this
888 890
         // new recvonly channel to the rest of the peers.
889
-        console.log('modify sources done');
891
+        logger.log('modify sources done');
890 892
 
891 893
         var newSdp = new SDP(self.peerconnection.localDescription.sdp);
892
-        console.log("SDPs", mySdp, newSdp);
894
+        logger.log("SDPs", mySdp, newSdp);
893 895
         self.notifyMySSRCUpdate(mySdp, newSdp);
894 896
     });
895 897
 };
@@ -900,7 +902,7 @@ JingleSessionPC.prototype.removeSource = function (elem, fromJid) {
900 902
     // FIXME: dirty waiting
901 903
     if (!this.peerconnection.localDescription)
902 904
     {
903
-        console.warn("removeSource - localDescription not ready yet")
905
+        logger.warn("removeSource - localDescription not ready yet")
904 906
         setTimeout(function()
905 907
             {
906 908
                 self.removeSource(elem, fromJid);
@@ -910,8 +912,8 @@ JingleSessionPC.prototype.removeSource = function (elem, fromJid) {
910 912
         return;
911 913
     }
912 914
 
913
-    console.log('removessrc', new Date().getTime());
914
-    console.log('ice', this.peerconnection.iceConnectionState);
915
+    logger.log('removessrc', new Date().getTime());
916
+    logger.log('ice', this.peerconnection.iceConnectionState);
915 917
     var sdp = new SDP(this.peerconnection.remoteDescription.sdp);
916 918
     var mySdp = new SDP(this.peerconnection.localDescription.sdp);
917 919
 
@@ -933,7 +935,7 @@ JingleSessionPC.prototype.removeSource = function (elem, fromJid) {
933 935
             var ssrc = $(this).attr('ssrc');
934 936
             // This should never happen, but can be useful for bug detection
935 937
             if(mySdp.containsSSRC(ssrc)){
936
-                console.error("Got remove stream request for my own ssrc: "+ssrc);
938
+                logger.error("Got remove stream request for my own ssrc: "+ssrc);
937 939
                 return;
938 940
             }
939 941
             $(this).find('>parameter').each(function () {
@@ -957,10 +959,10 @@ JingleSessionPC.prototype.removeSource = function (elem, fromJid) {
957 959
         // When a source is removed and if this is FF, the recvonly channel that
958 960
         // receives the remote stream is deactivated . We need to diffuse the
959 961
         // recvonly SSRC removal to the rest of the peers.
960
-        console.log('modify sources done');
962
+        logger.log('modify sources done');
961 963
 
962 964
         var newSdp = new SDP(self.peerconnection.localDescription.sdp);
963
-        console.log("SDPs", mySdp, newSdp);
965
+        logger.log("SDPs", mySdp, newSdp);
964 966
         self.notifyMySSRCUpdate(mySdp, newSdp);
965 967
     });
966 968
 };
@@ -1007,7 +1009,7 @@ JingleSessionPC.prototype._modifySources = function (successCallback, queueCallb
1007 1009
         function() {
1008 1010
 
1009 1011
             if(self.signalingState == 'closed') {
1010
-                console.error("createAnswer attempt on closed state");
1012
+                logger.error("createAnswer attempt on closed state");
1011 1013
                 queueCallback("createAnswer attempt on closed state");
1012 1014
                 return;
1013 1015
             }
@@ -1034,13 +1036,13 @@ JingleSessionPC.prototype._modifySources = function (successCallback, queueCallb
1034 1036
 
1035 1037
                     // FIXME: pushing down an answer while ice connection state
1036 1038
                     // is still checking is bad...
1037
-                    //console.log(self.peerconnection.iceConnectionState);
1039
+                    //logger.log(self.peerconnection.iceConnectionState);
1038 1040
 
1039 1041
                     // trying to work around another chrome bug
1040 1042
                     //modifiedAnswer.sdp = modifiedAnswer.sdp.replace(/a=setup:active/g, 'a=setup:actpass');
1041 1043
                     self.peerconnection.setLocalDescription(modifiedAnswer,
1042 1044
                         function() {
1043
-                            //console.log('modified setLocalDescription ok');
1045
+                            //logger.log('modified setLocalDescription ok');
1044 1046
                             self.setLocalDescription();
1045 1047
                             if(successCallback){
1046 1048
                                 successCallback();
@@ -1048,19 +1050,19 @@ JingleSessionPC.prototype._modifySources = function (successCallback, queueCallb
1048 1050
                             queueCallback();
1049 1051
                         },
1050 1052
                         function(error) {
1051
-                            console.error('modified setLocalDescription failed', error);
1053
+                            logger.error('modified setLocalDescription failed', error);
1052 1054
                             queueCallback(error);
1053 1055
                         }
1054 1056
                     );
1055 1057
                 },
1056 1058
                 function(error) {
1057
-                    console.error('modified answer failed', error);
1059
+                    logger.error('modified answer failed', error);
1058 1060
                     queueCallback(error);
1059 1061
                 }
1060 1062
             );
1061 1063
         },
1062 1064
         function(error) {
1063
-            console.error('modify failed', error);
1065
+            logger.error('modify failed', error);
1064 1066
             queueCallback(error);
1065 1067
         }
1066 1068
     );
@@ -1096,12 +1098,12 @@ JingleSessionPC.prototype.switchStreams = function (new_stream, oldStream, succe
1096 1098
 
1097 1099
     self.switchstreams = true;
1098 1100
     self.modifySourcesQueue.push(function() {
1099
-        console.log('modify sources done');
1101
+        logger.log('modify sources done');
1100 1102
 
1101 1103
         success_callback();
1102 1104
 
1103 1105
         var newSdp = new SDP(self.peerconnection.localDescription.sdp);
1104
-        console.log("SDPs", oldSdp, newSdp);
1106
+        logger.log("SDPs", oldSdp, newSdp);
1105 1107
         self.notifyMySSRCUpdate(oldSdp, newSdp);
1106 1108
     });
1107 1109
 };
@@ -1133,12 +1135,12 @@ JingleSessionPC.prototype.addStream = function (stream, callback) {
1133 1135
 
1134 1136
     this.addingStreams = true;
1135 1137
     this.modifySourcesQueue.push(function() {
1136
-        console.log('modify sources done');
1138
+        logger.log('modify sources done');
1137 1139
 
1138 1140
         callback();
1139 1141
 
1140 1142
         var newSdp = new SDP(self.peerconnection.localDescription.sdp);
1141
-        console.log("SDPs", oldSdp, newSdp);
1143
+        logger.log("SDPs", oldSdp, newSdp);
1142 1144
         self.notifyMySSRCUpdate(oldSdp, newSdp);
1143 1145
     });
1144 1146
 }
@@ -1152,7 +1154,7 @@ JingleSessionPC.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) {
1152 1154
 
1153 1155
     if (!(this.peerconnection.signalingState == 'stable' &&
1154 1156
         this.peerconnection.iceConnectionState == 'connected')){
1155
-        console.log("Too early to send updates");
1157
+        logger.log("Too early to send updates");
1156 1158
         return;
1157 1159
     }
1158 1160
 
@@ -1174,17 +1176,17 @@ JingleSessionPC.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) {
1174 1176
         remove = SSRCReplacement.processSourceRemove(remove);
1175 1177
 
1176 1178
     if (removed && remove) {
1177
-        console.info("Sending source-remove", remove);
1179
+        logger.info("Sending source-remove", remove);
1178 1180
         this.connection.sendIQ(remove,
1179 1181
             function (res) {
1180
-                console.info('got remove result', res);
1182
+                logger.info('got remove result', res);
1181 1183
             },
1182 1184
             function (err) {
1183
-                console.error('got remove error', err);
1185
+                logger.error('got remove error', err);
1184 1186
             }
1185 1187
         );
1186 1188
     } else {
1187
-        console.log('removal not necessary');
1189
+        logger.log('removal not necessary');
1188 1190
     }
1189 1191
 
1190 1192
     // send source-add IQ.
@@ -1205,17 +1207,17 @@ JingleSessionPC.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) {
1205 1207
         add = SSRCReplacement.processSourceAdd(add);
1206 1208
 
1207 1209
     if (added && add) {
1208
-        console.info("Sending source-add", add);
1210
+        logger.info("Sending source-add", add);
1209 1211
         this.connection.sendIQ(add,
1210 1212
             function (res) {
1211
-                console.info('got add result', res);
1213
+                logger.info('got add result', res);
1212 1214
             },
1213 1215
             function (err) {
1214
-                console.error('got add error', err);
1216
+                logger.error('got add error', err);
1215 1217
             }
1216 1218
         );
1217 1219
     } else {
1218
-        console.log('addition not necessary');
1220
+        logger.log('addition not necessary');
1219 1221
     }
1220 1222
 };
1221 1223
 
@@ -1263,12 +1265,12 @@ JingleSessionPC.prototype.setVideoMute = function (mute, callback, options) {
1263 1265
     }
1264 1266
 
1265 1267
     this.modifySourcesQueue.push(function() {
1266
-        console.log('modify sources done');
1268
+        logger.log('modify sources done');
1267 1269
 
1268 1270
         callback(mute);
1269 1271
 
1270 1272
         var newSdp = new SDP(self.peerconnection.localDescription.sdp);
1271
-        console.log("SDPs", oldSdp, newSdp);
1273
+        logger.log("SDPs", oldSdp, newSdp);
1272 1274
         self.notifyMySSRCUpdate(oldSdp, newSdp);
1273 1275
     });
1274 1276
 };
@@ -1351,7 +1353,7 @@ JingleSessionPC.prototype.getStats = function (interval) {
1351 1353
 
1352 1354
 JingleSessionPC.onJingleError = function (session, error)
1353 1355
 {
1354
-    console.error("Jingle error", error);
1356
+    logger.error("Jingle error", error);
1355 1357
 }
1356 1358
 
1357 1359
 JingleSessionPC.onJingleFatalError = function (session, error)
@@ -1388,7 +1390,7 @@ JingleSessionPC.prototype.setLocalDescription = function () {
1388 1390
 
1389 1391
     });
1390 1392
 
1391
-    console.log('new ssrcs', newssrcs);
1393
+    logger.log('new ssrcs', newssrcs);
1392 1394
 
1393 1395
     // Bind us as local SSRCs owner
1394 1396
     if (newssrcs.length > 0) {
@@ -1403,7 +1405,7 @@ JingleSessionPC.prototype.setLocalDescription = function () {
1403 1405
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
1404 1406
 JingleSessionPC.prototype.sendKeyframe = function () {
1405 1407
     var pc = this.peerconnection;
1406
-    console.log('sendkeyframe', pc.iceConnectionState);
1408
+    logger.log('sendkeyframe', pc.iceConnectionState);
1407 1409
     if (pc.iceConnectionState !== 'connected') return; // safe...
1408 1410
     var self = this;
1409 1411
     pc.setRemoteDescription(
@@ -1417,19 +1419,19 @@ JingleSessionPC.prototype.sendKeyframe = function () {
1417 1419
                             // noop
1418 1420
                         },
1419 1421
                         function (error) {
1420
-                            console.log('triggerKeyframe setLocalDescription failed', error);
1422
+                            logger.log('triggerKeyframe setLocalDescription failed', error);
1421 1423
                             self.room.eventEmitter.emit(XMPPEvents.SET_LOCAL_DESCRIPTION_ERROR);
1422 1424
                         }
1423 1425
                     );
1424 1426
                 },
1425 1427
                 function (error) {
1426
-                    console.log('triggerKeyframe createAnswer failed', error);
1428
+                    logger.log('triggerKeyframe createAnswer failed', error);
1427 1429
                     self.room.eventEmitter.emit(XMPPEvents.CREATE_ANSWER_ERROR);
1428 1430
                 }
1429 1431
             );
1430 1432
         },
1431 1433
         function (error) {
1432
-            console.log('triggerKeyframe setRemoteDescription failed', error);
1434
+            logger.log('triggerKeyframe setRemoteDescription failed', error);
1433 1435
             eventEmitter.emit(XMPPEvents.SET_REMOTE_DESCRIPTION_ERROR);
1434 1436
         }
1435 1437
     );
@@ -1443,7 +1445,7 @@ JingleSessionPC.prototype.remoteStreamAdded = function (data, times) {
1443 1445
 
1444 1446
     // look up an associated JID for a stream id
1445 1447
     if (!streamId) {
1446
-        console.error("No stream ID for", data.stream);
1448
+        logger.error("No stream ID for", data.stream);
1447 1449
     } else if (streamId && streamId.indexOf('mixedmslabel') === -1) {
1448 1450
         // look only at a=ssrc: and _not_ at a=ssrc-group: lines
1449 1451
 
@@ -1464,13 +1466,13 @@ JingleSessionPC.prototype.remoteStreamAdded = function (data, times) {
1464 1466
             thessrc = ssrclines[0].substring(7).split(' ')[0];
1465 1467
 
1466 1468
             if (!self.ssrcOwners[thessrc]) {
1467
-                console.error("No SSRC owner known for: " + thessrc);
1469
+                logger.error("No SSRC owner known for: " + thessrc);
1468 1470
                 return;
1469 1471
             }
1470 1472
             data.peerjid = self.ssrcOwners[thessrc];
1471
-            console.log('associated jid', self.ssrcOwners[thessrc]);
1473
+            logger.log('associated jid', self.ssrcOwners[thessrc]);
1472 1474
         } else {
1473
-            console.error("No SSRC lines for ", streamId);
1475
+            logger.error("No SSRC lines for ", streamId);
1474 1476
         }
1475 1477
     }
1476 1478
 

+ 9
- 7
modules/xmpp/LocalSSRCReplacement.js View File

@@ -1,4 +1,6 @@
1 1
 /* global $ */
2
+var logger = require("jitsi-meet-logger").getLogger(__filename);
3
+
2 4
 
3 5
 /*
4 6
  Here we do modifications of local video SSRCs. There are 2 situations we have
@@ -84,7 +86,7 @@ var filterOutSource = function (modifyIq, actionName) {
84 86
         return modifyIqTree[0];
85 87
     }
86 88
 
87
-    console.info(
89
+    logger.info(
88 90
         'Blocking ' + actionName + ' for local video SSRC: ' + localVideoSSRC);
89 91
 
90 92
     videoSSRC.remove();
@@ -118,7 +120,7 @@ var storeLocalVideoSSRC = function (jingleIq) {
118 120
             var ssrcVal = ssrSel.attr('ssrc');
119 121
             if (ssrcVal) {
120 122
                 localVideoSSRC = ssrcVal;
121
-                console.info('Stored local video SSRC' +
123
+                logger.info('Stored local video SSRC' +
122 124
                              ' for future re-use: ' + localVideoSSRC);
123 125
             }
124 126
         }
@@ -148,7 +150,7 @@ function generateRecvonlySSRC() {
148 150
     localRecvOnlyMSID = localRecvOnlyMSLabel + " " + localRecvOnlyLabel;
149 151
 
150 152
 
151
-        console.info(
153
+        logger.info(
152 154
         "Generated local recvonly SSRC: " + localRecvOnlySSRC +
153 155
         ", cname: " + localRecvOnlyCName);
154 156
 }
@@ -166,7 +168,7 @@ var LocalSSRCReplacement = {
166 168
             return;
167 169
 
168 170
         if (localVideoSSRC) {
169
-            console.error("Local SSRC stored already: " + localVideoSSRC);
171
+            logger.error("Local SSRC stored already: " + localVideoSSRC);
170 172
             return;
171 173
         }
172 174
         storeLocalVideoSSRC(sessionInit);
@@ -184,7 +186,7 @@ var LocalSSRCReplacement = {
184 186
             return localDescription;
185 187
 
186 188
         if (!localDescription) {
187
-            console.warn("localDescription is null or undefined");
189
+            logger.warn("localDescription is null or undefined");
188 190
             return localDescription;
189 191
         }
190 192
 
@@ -200,7 +202,7 @@ var LocalSSRCReplacement = {
200 202
                 var videoSSRCs = videoPart.ssrcs;
201 203
                 var newSSRC = Object.keys(videoSSRCs)[0];
202 204
 
203
-                console.info(
205
+                logger.info(
204 206
                     "Replacing new video SSRC: " + newSSRC +
205 207
                     " with " + localVideoSSRC);
206 208
 
@@ -221,7 +223,7 @@ var LocalSSRCReplacement = {
221 223
                 }
222 224
                 localVideoSSRC = localRecvOnlySSRC;
223 225
 
224
-                console.info('No SSRC in video recvonly stream' +
226
+                logger.info('No SSRC in video recvonly stream' +
225 227
                              ' - adding SSRC: ' + localRecvOnlySSRC);
226 228
 
227 229
                 sdp.media[1] += 'a=ssrc:' + localRecvOnlySSRC +

+ 4
- 2
modules/xmpp/SDP.js View File

@@ -1,4 +1,6 @@
1 1
 /* jshint -W117 */
2
+
3
+var logger = require("jitsi-meet-logger").getLogger(__filename);
2 4
 var SDPUtil = require("./SDPUtil");
3 5
 
4 6
 // SDP STUFF
@@ -65,7 +67,7 @@ SDP.prototype.containsSSRC = function(ssrc) {
65 67
     var contains = false;
66 68
     Object.keys(medias).forEach(function(mediaindex){
67 69
         var media = medias[mediaindex];
68
-        //console.log("Check", channel, ssrc);
70
+        //logger.log("Check", channel, ssrc);
69 71
         if(Object.keys(media.ssrcs).indexOf(ssrc) != -1){
70 72
             contains = true;
71 73
         }
@@ -126,7 +128,7 @@ SDP.prototype.removeMediaLines = function(mediaindex, prefix) {
126 128
 
127 129
 // add content's to a jingle element
128 130
 SDP.prototype.toJingle = function (elem, thecreator, ssrcs) {
129
-//    console.log("SSRC" + ssrcs["audio"] + " - " + ssrcs["video"]);
131
+//    logger.log("SSRC" + ssrcs["audio"] + " - " + ssrcs["video"]);
130 132
     var i, j, k, mline, ssrc, rtpmap, tmp, line, lines;
131 133
     var self = this;
132 134
     // new bundle plan

+ 8
- 6
modules/xmpp/SDPUtil.js View File

@@ -1,3 +1,5 @@
1
+
2
+var logger = require("jitsi-meet-logger").getLogger(__filename);
1 3
 SDPUtil = {
2 4
     filter_special_chars: function (text) {
3 5
         return text.replace(/[\\\/\{,\}\+]/g, "");
@@ -141,7 +143,7 @@ SDPUtil = {
141 143
                     candidate.tcptype = elems[i + 1];
142 144
                     break;
143 145
                 default: // TODO
144
-                    console.log('parse_icecandidate not translating "' + elems[i] + '" = "' + elems[i + 1] + '"');
146
+                    logger.log('parse_icecandidate not translating "' + elems[i] + '" = "' + elems[i + 1] + '"');
145 147
             }
146 148
         }
147 149
         candidate.network = '1';
@@ -258,8 +260,8 @@ SDPUtil = {
258 260
         if (line.indexOf('candidate:') === 0) {
259 261
             line = 'a=' + line;
260 262
         } else if (line.substring(0, 12) != 'a=candidate:') {
261
-            console.log('parseCandidate called with a line that is not a candidate line');
262
-            console.log(line);
263
+            logger.log('parseCandidate called with a line that is not a candidate line');
264
+            logger.log(line);
263 265
             return null;
264 266
         }
265 267
         if (line.substring(line.length - 2) == '\r\n') // chomp it
@@ -268,8 +270,8 @@ SDPUtil = {
268 270
             elems = line.split(' '),
269 271
             i;
270 272
         if (elems[6] != 'typ') {
271
-            console.log('did not find typ in the right place');
272
-            console.log(line);
273
+            logger.log('did not find typ in the right place');
274
+            logger.log(line);
273 275
             return null;
274 276
         }
275 277
         candidate.foundation = elems[0].substring(12);
@@ -297,7 +299,7 @@ SDPUtil = {
297 299
                     candidate.tcptype = elems[i + 1];
298 300
                     break;
299 301
                 default: // TODO
300
-                    console.log('not translating "' + elems[i] + '" = "' + elems[i + 1] + '"');
302
+                    logger.log('not translating "' + elems[i] + '" = "' + elems[i + 1] + '"');
301 303
             }
302 304
         }
303 305
         candidate.network = '1';

+ 8
- 6
modules/xmpp/TraceablePeerConnection.js View File

@@ -1,4 +1,6 @@
1 1
 var RTC = require('../RTC/RTC');
2
+
3
+var logger = require("jitsi-meet-logger").getLogger(__filename);
2 4
 var RTCBrowserType = require("../RTC/RTCBrowserType.js");
3 5
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
4 6
 var SSRCReplacement = require("./LocalSSRCReplacement");
@@ -26,13 +28,13 @@ function TraceablePeerConnection(ice_config, constraints, session) {
26 28
 
27 29
     // override as desired
28 30
     this.trace = function (what, info) {
29
-        /*console.warn('WTRACE', what, info);
31
+        /*logger.warn('WTRACE', what, info);
30 32
         if (info && RTCBrowserType.isIExplorer()) {
31 33
             if (info.length > 1024) {
32
-                console.warn('WTRACE', what, info.substr(1024));
34
+                logger.warn('WTRACE', what, info.substr(1024));
33 35
             }
34 36
             if (info.length > 2048) {
35
-                console.warn('WTRACE', what, info.substr(2048));
37
+                logger.warn('WTRACE', what, info.substr(2048));
36 38
             }
37 39
         }*/
38 40
         self.updateLog.push({
@@ -142,7 +144,7 @@ var dumpSDP = function(description) {
142 144
 var normalizePlanB = function(desc) {
143 145
     if (typeof desc !== 'object' || desc === null ||
144 146
         typeof desc.sdp !== 'string') {
145
-        console.warn('An empty description was passed as an argument.');
147
+        logger.warn('An empty description was passed as an argument.');
146 148
         return desc;
147 149
     }
148 150
 
@@ -248,7 +250,7 @@ TraceablePeerConnection.prototype.addStream = function (stream) {
248 250
     }
249 251
     catch (e)
250 252
     {
251
-        console.error(e);
253
+        logger.error(e);
252 254
     }
253 255
 };
254 256
 
@@ -277,7 +279,7 @@ TraceablePeerConnection.prototype.removeStream = function (stream, stopStreams)
277 279
         if (this.peerconnection.removeStream)
278 280
             this.peerconnection.removeStream(stream);
279 281
     } catch (e) {
280
-        console.error(e);
282
+        logger.error(e);
281 283
     }
282 284
 };
283 285
 

+ 23
- 21
modules/xmpp/moderator.js View File

@@ -1,5 +1,7 @@
1 1
 /* global $, $iq, APP, config, messageHandler,
2 2
  roomName, sessionTerminated, Strophe, Util */
3
+
4
+var logger = require("jitsi-meet-logger").getLogger(__filename);
3 5
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
4 6
 var Settings = require("../settings/Settings");
5 7
 
@@ -47,7 +49,7 @@ function Moderator(roomName, xmpp, emitter) {
47 49
     function listener(event) {
48 50
         if (event.data && event.data.sessionId) {
49 51
             if (event.origin !== window.location.origin) {
50
-                console.warn("Ignoring sessionId from different origin: " +
52
+                logger.warn("Ignoring sessionId from different origin: " +
51 53
                     event.origin);
52 54
                 return;
53 55
             }
@@ -73,10 +75,10 @@ Moderator.prototype.isSipGatewayEnabled =  function () {
73 75
 
74 76
 
75 77
 Moderator.prototype.onMucMemberLeft =  function (jid) {
76
-    console.info("Someone left is it focus ? " + jid);
78
+    logger.info("Someone left is it focus ? " + jid);
77 79
     var resource = Strophe.getResourceFromJid(jid);
78 80
     if (resource === 'focus' && !this.xmppService.sessionTerminated) {
79
-        console.info(
81
+        logger.info(
80 82
             "Focus has left the room - leaving conference");
81 83
         //hangUp();
82 84
         // We'd rather reload to have everything re-initialized
@@ -89,7 +91,7 @@ Moderator.prototype.onMucMemberLeft =  function (jid) {
89 91
 Moderator.prototype.setFocusUserJid =  function (focusJid) {
90 92
     if (!this.focusUserJid) {
91 93
         this.focusUserJid = focusJid;
92
-        console.info("Focus jid set to:  " + this.focusUserJid);
94
+        logger.info("Focus jid set to:  " + this.focusUserJid);
93 95
     }
94 96
 };
95 97
 
@@ -116,7 +118,7 @@ Moderator.prototype.createConferenceIq =  function () {
116 118
     var sessionId = localStorage.getItem('sessionId');
117 119
     var machineUID = this.settings.getSettings().uid;
118 120
 
119
-    console.info(
121
+    logger.info(
120 122
             "Session ID: " + sessionId + " machine UID: " + machineUID);
121 123
 
122 124
     elem.c('conference', {
@@ -191,7 +193,7 @@ Moderator.prototype.createConferenceIq =  function () {
191 193
 Moderator.prototype.parseSessionId =  function (resultIq) {
192 194
     var sessionId = $(resultIq).find('conference').attr('session-id');
193 195
     if (sessionId) {
194
-        console.info('Received sessionId:  ' + sessionId);
196
+        logger.info('Received sessionId:  ' + sessionId);
195 197
         localStorage.setItem('sessionId', sessionId);
196 198
     }
197 199
 };
@@ -206,13 +208,13 @@ Moderator.prototype.parseConfigOptions =  function (resultIq) {
206 208
             '>conference>property' +
207 209
             '[name=\'authentication\'][value=\'true\']').length > 0;
208 210
 
209
-    console.info("Authentication enabled: " + authenticationEnabled);
211
+    logger.info("Authentication enabled: " + authenticationEnabled);
210 212
 
211 213
     this.externalAuthEnabled = $(resultIq).find(
212 214
             '>conference>property' +
213 215
             '[name=\'externalAuth\'][value=\'true\']').length > 0;
214 216
 
215
-    console.info('External authentication enabled: ' + this.externalAuthEnabled);
217
+    logger.info('External authentication enabled: ' + this.externalAuthEnabled);
216 218
 
217 219
     if (!this.externalAuthEnabled) {
218 220
         // We expect to receive sessionId in 'internal' authentication mode
@@ -232,7 +234,7 @@ Moderator.prototype.parseConfigOptions =  function (resultIq) {
232 234
         this.sipGatewayEnabled = true;
233 235
     }
234 236
 
235
-    console.info("Sip gateway enabled:  " + this.sipGatewayEnabled);
237
+    logger.info("Sip gateway enabled:  " + this.sipGatewayEnabled);
236 238
 };
237 239
 
238 240
 // FIXME =  we need to show the fact that we're waiting for the focus
@@ -258,7 +260,7 @@ Moderator.prototype.allocateConferenceFocus =  function ( callback) {
258 260
                 callback();
259 261
             } else {
260 262
                 var waitMs = self.getNextTimeout();
261
-                console.info("Waiting for the focus... " + waitMs);
263
+                logger.info("Waiting for the focus... " + waitMs);
262 264
                 // Reset error timeout
263 265
                 self.getNextErrorTimeout(true);
264 266
                 window.setTimeout(
@@ -273,7 +275,7 @@ Moderator.prototype.allocateConferenceFocus =  function ( callback) {
273 275
             var invalidSession
274 276
                 = $(error).find('>error>session-invalid').length;
275 277
             if (invalidSession) {
276
-                console.info("Session expired! - removing");
278
+                logger.info("Session expired! - removing");
277 279
                 localStorage.removeItem("sessionId");
278 280
             }
279 281
             if ($(error).find('>error>graceful-shutdown').length) {
@@ -295,7 +297,7 @@ Moderator.prototype.allocateConferenceFocus =  function ( callback) {
295 297
             }
296 298
             // Not authorized to create new room
297 299
             if ($(error).find('>error>not-authorized').length) {
298
-                console.warn("Unauthorized to start the conference", error);
300
+                logger.warn("Unauthorized to start the conference", error);
299 301
                 var toDomain
300 302
                     = Strophe.getDomainFromJid(error.getAttribute('to'));
301 303
                 if (toDomain !== this.xmppService.options.hosts.anonymousdomain) {
@@ -312,7 +314,7 @@ Moderator.prototype.allocateConferenceFocus =  function ( callback) {
312 314
                 return;
313 315
             }
314 316
             var waitMs = self.getNextErrorTimeout();
315
-            console.error("Focus error, retry after " + waitMs, error);
317
+            logger.error("Focus error, retry after " + waitMs, error);
316 318
             // Show message
317 319
             var focusComponent = self.getFocusComponent();
318 320
             var retrySec = waitMs / 1000;
@@ -346,15 +348,15 @@ Moderator.prototype.getLoginUrl =  function (urlCallback) {
346 348
             var url = $(result).find('login-url').attr('url');
347 349
             url = url = decodeURIComponent(url);
348 350
             if (url) {
349
-                console.info("Got auth url: " + url);
351
+                logger.info("Got auth url: " + url);
350 352
                 urlCallback(url);
351 353
             } else {
352
-                console.error(
354
+                logger.error(
353 355
                     "Failed to get auth url from the focus", result);
354 356
             }
355 357
         },
356 358
         function (error) {
357
-            console.error("Get auth url error", error);
359
+            logger.error("Get auth url error", error);
358 360
         }
359 361
     );
360 362
 };
@@ -372,15 +374,15 @@ Moderator.prototype.getPopupLoginUrl =  function (urlCallback) {
372 374
             var url = $(result).find('login-url').attr('url');
373 375
             url = url = decodeURIComponent(url);
374 376
             if (url) {
375
-                console.info("Got POPUP auth url:  " + url);
377
+                logger.info("Got POPUP auth url:  " + url);
376 378
                 urlCallback(url);
377 379
             } else {
378
-                console.error(
380
+                logger.error(
379 381
                     "Failed to get POPUP auth url from the focus", result);
380 382
             }
381 383
         },
382 384
         function (error) {
383
-            console.error('Get POPUP auth url error', error);
385
+            logger.error('Get POPUP auth url error', error);
384 386
         }
385 387
     );
386 388
 };
@@ -403,12 +405,12 @@ Moderator.prototype.logout =  function (callback) {
403 405
             if (logoutUrl) {
404 406
                 logoutUrl = decodeURIComponent(logoutUrl);
405 407
             }
406
-            console.info("Log out OK, url: " + logoutUrl, result);
408
+            logger.info("Log out OK, url: " + logoutUrl, result);
407 409
             localStorage.removeItem('sessionId');
408 410
             callback(logoutUrl);
409 411
         },
410 412
         function (error) {
411
-            console.error("Logout error", error);
413
+            logger.error("Logout error", error);
412 414
         }
413 415
     );
414 416
 };

+ 3
- 1
modules/xmpp/strophe.emuc.js View File

@@ -2,6 +2,8 @@
2 2
 /* a simple MUC connection plugin
3 3
  * can only handle a single MUC room
4 4
  */
5
+
6
+var logger = require("jitsi-meet-logger").getLogger(__filename);
5 7
 var ChatRoom = require("./ChatRoom");
6 8
 
7 9
 module.exports = function(XMPP) {
@@ -19,7 +21,7 @@ module.exports = function(XMPP) {
19 21
         createRoom: function (jid, password, options) {
20 22
             var roomJid = Strophe.getBareJidFromJid(jid);
21 23
             if (this.rooms[roomJid]) {
22
-                console.error("You are already in the room!");
24
+                logger.error("You are already in the room!");
23 25
                 return;
24 26
             }
25 27
             this.rooms[roomJid] = new ChatRoom(this.connection, jid, password, XMPP, options);

+ 9
- 7
modules/xmpp/strophe.jingle.js View File

@@ -1,5 +1,7 @@
1 1
 /* jshint -W117 */
2 2
 
3
+
4
+var logger = require("jitsi-meet-logger").getLogger(__filename);
3 5
 var JingleSession = require("./JingleSessionPC");
4 6
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
5 7
 var RTCBrowserType = require("../RTC/RTCBrowserType");
@@ -56,7 +58,7 @@ module.exports = function(XMPP, eventEmitter) {
56 58
                 to: fromJid,
57 59
                 id: iq.getAttribute('id')
58 60
             });
59
-            console.log('on jingle ' + action + ' from ' + fromJid, iq);
61
+            logger.log('on jingle ' + action + ' from ' + fromJid, iq);
60 62
             var sess = this.sessions[sid];
61 63
             if ('session-initiate' != action) {
62 64
                 if (sess === null) {
@@ -69,7 +71,7 @@ module.exports = function(XMPP, eventEmitter) {
69 71
                 }
70 72
                 // local jid is not checked
71 73
                 if (fromJid != sess.peerjid) {
72
-                    console.warn('jid mismatch for session id', sid, fromJid, sess.peerjid);
74
+                    logger.warn('jid mismatch for session id', sid, fromJid, sess.peerjid);
73 75
                     ack.type = 'error';
74 76
                     ack.c('error', {type: 'cancel'})
75 77
                         .c('item-not-found', {xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas'}).up()
@@ -83,7 +85,7 @@ module.exports = function(XMPP, eventEmitter) {
83 85
                 ack.type = 'error';
84 86
                 ack.c('error', {type: 'cancel'})
85 87
                     .c('service-unavailable', {xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas'}).up();
86
-                console.warn('duplicate session id', sid);
88
+                logger.warn('duplicate session id', sid);
87 89
                 this.connection.send(ack);
88 90
                 return true;
89 91
             }
@@ -138,7 +140,7 @@ module.exports = function(XMPP, eventEmitter) {
138 140
                     {
139 141
                         break;
140 142
                     }
141
-                    console.log('terminating...', sess.sid);
143
+                    logger.log('terminating...', sess.sid);
142 144
                     sess.terminate();
143 145
                     this.terminate(sess.sid);
144 146
                     if ($(iq).find('>jingle>reason').length) {
@@ -177,7 +179,7 @@ module.exports = function(XMPP, eventEmitter) {
177 179
                     sess.removeSource($(iq).find('>jingle>content'), fromJid);
178 180
                     break;
179 181
                 default:
180
-                    console.warn('jingle action not implemented', action);
182
+                    logger.warn('jingle action not implemented', action);
181 183
                     break;
182 184
             }
183 185
             return true;
@@ -258,8 +260,8 @@ module.exports = function(XMPP, eventEmitter) {
258 260
                     self.ice_config.iceServers = iceservers;
259 261
                 },
260 262
                 function (err) {
261
-                    console.warn('getting turn credentials failed', err);
262
-                    console.warn('is mod_turncredentials or similar installed?');
263
+                    logger.warn('getting turn credentials failed', err);
264
+                    logger.warn('is mod_turncredentials or similar installed?');
263 265
                 }
264 266
             );
265 267
             // implement push?

+ 6
- 4
modules/xmpp/strophe.moderate.js View File

@@ -3,6 +3,8 @@
3 3
 /**
4 4
  * Moderate connection plugin.
5 5
  */
6
+
7
+var logger = require("jitsi-meet-logger").getLogger(__filename);
6 8
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
7 9
 
8 10
 module.exports = function (XMPP, eventEmitter) {
@@ -19,7 +21,7 @@ module.exports = function (XMPP, eventEmitter) {
19 21
                 null);
20 22
         },
21 23
         setMute: function (jid, mute) {
22
-            console.info("set mute", mute);
24
+            logger.info("set mute", mute);
23 25
             var iqToFocus = $iq({to: this.connection.emuc.focusMucJid, type: 'set'})
24 26
                 .c('mute', {
25 27
                     xmlns: 'http://jitsi.org/jitmeet/audio',
@@ -31,16 +33,16 @@ module.exports = function (XMPP, eventEmitter) {
31 33
             this.connection.sendIQ(
32 34
                 iqToFocus,
33 35
                 function (result) {
34
-                    console.log('set mute', result);
36
+                    logger.log('set mute', result);
35 37
                 },
36 38
                 function (error) {
37
-                    console.log('set mute error', error);
39
+                    logger.log('set mute error', error);
38 40
                 });
39 41
         },
40 42
         onMute: function (iq) {
41 43
             var from = iq.getAttribute('from');
42 44
             if (from !== this.connection.emuc.focusMucJid) {
43
-                console.warn("Ignored mute from non focus peer");
45
+                logger.warn("Ignored mute from non focus peer");
44 46
                 return false;
45 47
             }
46 48
             var mute = $(iq).find('mute');

+ 9
- 7
modules/xmpp/strophe.rayo.js View File

@@ -1,4 +1,6 @@
1 1
 /* jshint -W117 */
2
+var logger = require("jitsi-meet-logger").getLogger(__filename);
3
+
2 4
 module.exports = function() {
3 5
     Strophe.addConnectionPlugin('rayo',
4 6
         {
@@ -14,7 +16,7 @@ module.exports = function() {
14 16
                     this.onRayo.bind(this), this.RAYO_XMLNS, 'iq', 'set', null, null);
15 17
             },
16 18
             onRayo: function (iq) {
17
-                console.info("Rayo IQ", iq);
19
+                logger.info("Rayo IQ", iq);
18 20
             },
19 21
             dial: function (to, from, roomName, roomPass) {
20 22
                 var self = this;
@@ -48,21 +50,21 @@ module.exports = function() {
48 50
                 this.connection.sendIQ(
49 51
                     req,
50 52
                     function (result) {
51
-                        console.info('Dial result ', result);
53
+                        logger.info('Dial result ', result);
52 54
 
53 55
                         var resource = $(result).find('ref').attr('uri');
54 56
                         this.call_resource = resource.substr('xmpp:'.length);
55
-                        console.info(
57
+                        logger.info(
56 58
                                 "Received call resource: " + this.call_resource);
57 59
                     },
58 60
                     function (error) {
59
-                        console.info('Dial error ', error);
61
+                        logger.info('Dial error ', error);
60 62
                     }
61 63
                 );
62 64
             },
63 65
             hang_up: function () {
64 66
                 if (!this.call_resource) {
65
-                    console.warn("No call in progress");
67
+                    logger.warn("No call in progress");
66 68
                     return;
67 69
                 }
68 70
 
@@ -81,11 +83,11 @@ module.exports = function() {
81 83
                 this.connection.sendIQ(
82 84
                     req,
83 85
                     function (result) {
84
-                        console.info('Hangup result ', result);
86
+                        logger.info('Hangup result ', result);
85 87
                         self.call_resource = null;
86 88
                     },
87 89
                     function (error) {
88
-                        console.info('Hangup error ', error);
90
+                        logger.info('Hangup error ', error);
89 91
                         self.call_resource = null;
90 92
                     }
91 93
                 );

+ 4
- 2
modules/xmpp/strophe.util.js View File

@@ -1,16 +1,18 @@
1 1
 /**
2 2
  * Strophe logger implementation. Logs from level WARN and above.
3 3
  */
4
+var logger = require("jitsi-meet-logger").getLogger(__filename);
5
+
4 6
 module.exports = function () {
5 7
 
6 8
     Strophe.log = function (level, msg) {
7 9
         switch (level) {
8 10
             case Strophe.LogLevel.WARN:
9
-                console.warn("Strophe: " + msg);
11
+                logger.warn("Strophe: " + msg);
10 12
                 break;
11 13
             case Strophe.LogLevel.ERROR:
12 14
             case Strophe.LogLevel.FATAL:
13
-                console.error("Strophe: " + msg);
15
+                logger.error("Strophe: " + msg);
14 16
                 break;
15 17
         }
16 18
     };

+ 4
- 2
modules/xmpp/xmpp.js View File

@@ -1,4 +1,6 @@
1 1
 /* global $, APP, config, Strophe*/
2
+
3
+var logger = require("jitsi-meet-logger").getLogger(__filename);
2 4
 var EventEmitter = require("events");
3 5
 var Pako = require("pako");
4 6
 var StreamEventTypes = require("../../service/RTC/StreamEventTypes");
@@ -100,7 +102,7 @@ XMPP.prototype._connect = function (jid, password) {
100 102
     var connectionFailed = false;
101 103
     var lastErrorMsg;
102 104
     this.connection.connect(jid, password, function (status, msg) {
103
-        console.log('Strophe status changed to',
105
+        logger.log('Strophe status changed to',
104 106
             Strophe.getStatusString(status), msg);
105 107
         if (status === Strophe.Status.CONNECTED) {
106 108
             if (self.options.useStunTurn) {
@@ -108,7 +110,7 @@ XMPP.prototype._connect = function (jid, password) {
108 110
             }
109 111
 
110 112
 
111
-            console.info("My Jabber ID: " + self.connection.jid);
113
+            logger.info("My Jabber ID: " + self.connection.jid);
112 114
 
113 115
             if (password)
114 116
                 authenticatedUser = true;

+ 2
- 1
package.json View File

@@ -26,7 +26,8 @@
26 26
       "retry": "0.6.1",
27 27
       "jssha": "1.5.0",
28 28
       "socket.io-client": "1.3.6",
29
-      "es6-promise": "*"
29
+      "es6-promise": "*",
30
+      "jitsi-meet-logger": "jitsi/jitsi-meet-logger"
30 31
   },
31 32
   "devDependencies": {
32 33
     "browserify": "11.1.x",

Loading…
Cancel
Save