Przeglądaj źródła

Clean up logging and formatting. (#1378)

* ref: Do not include the full JSON when firing event (unused).

* ref: Logging and formatting fixes.
release-8443
bgrozev 5 lat temu
rodzic
commit
8154c5f601
No account linked to committer's email address
1 zmienionych plików z 18 dodań i 39 usunięć
  1. 18
    39
      modules/RTC/BridgeChannel.js

+ 18
- 39
modules/RTC/BridgeChannel.js Wyświetl plik

@@ -25,11 +25,9 @@ export default class BridgeChannel {
25 25
      */
26 26
     constructor(peerconnection, wsUrl, emitter, senderVideoConstraintsChanged) {
27 27
         if (!peerconnection && !wsUrl) {
28
-            throw new TypeError(
29
-                'At least peerconnection or wsUrl must be given');
28
+            throw new TypeError('At least peerconnection or wsUrl must be given');
30 29
         } else if (peerconnection && wsUrl) {
31
-            throw new TypeError(
32
-                'Just one of peerconnection or wsUrl must be given');
30
+            throw new TypeError('Just one of peerconnection or wsUrl must be given');
33 31
         }
34 32
 
35 33
         if (peerconnection) {
@@ -201,13 +199,12 @@ export default class BridgeChannel {
201 199
      * @param {number} value The new value for lastN. -1 means unlimited.
202 200
      */
203 201
     sendSetLastNMessage(value) {
204
-        const jsonObject = {
202
+        logger.log(`Sending lastN=${value}.`);
203
+
204
+        this._send({
205 205
             colibriClass: 'LastNChangedEvent',
206 206
             lastN: value
207
-        };
208
-
209
-        this._send(jsonObject);
210
-        logger.log(`Channel lastN set to: ${value}`);
207
+        });
211 208
     }
212 209
 
213 210
     /**
@@ -218,9 +215,7 @@ export default class BridgeChannel {
218 215
      * or from WebSocket#send or Error with "No opened channel" message.
219 216
      */
220 217
     sendPinnedEndpointMessage(endpointId) {
221
-        logger.log(
222
-            'sending pinned changed notification to the bridge for endpoint ',
223
-            endpointId);
218
+        logger.log(`Sending pinned endpoint: ${endpointId}.`);
224 219
 
225 220
         this._send({
226 221
             colibriClass: 'PinnedEndpointChangedEvent',
@@ -237,9 +232,7 @@ export default class BridgeChannel {
237 232
      * or from WebSocket#send or Error with "No opened channel" message.
238 233
      */
239 234
     sendSelectedEndpointsMessage(endpointIds) {
240
-        logger.log(
241
-            'sending selected changed notification to the bridge for endpoints',
242
-            endpointIds);
235
+        logger.log(`Sending selected endpoints: ${endpointIds}.`);
243 236
 
244 237
         this._send({
245 238
             colibriClass: 'SelectedEndpointsChangedEvent',
@@ -253,8 +246,7 @@ export default class BridgeChannel {
253 246
      * in pixels, this receiver is willing to receive
254 247
      */
255 248
     sendReceiverVideoConstraintMessage(maxFrameHeightPixels) {
256
-        logger.log('sending a ReceiverVideoConstraint message with '
257
-            + `a maxFrameHeight of ${maxFrameHeightPixels} pixels`);
249
+        logger.log(`Sending ReceiverVideoConstraint with maxFrameHeight=${maxFrameHeightPixels}px`);
258 250
         this._send({
259 251
             colibriClass: 'ReceiverVideoConstraint',
260 252
             maxFrameHeight: maxFrameHeightPixels
@@ -295,9 +287,7 @@ export default class BridgeChannel {
295 287
                 obj = JSON.parse(data);
296 288
             } catch (error) {
297 289
                 GlobalOnErrorHandler.callErrorHandler(error);
298
-                logger.error(
299
-                    'Failed to parse channel message as JSON: ',
300
-                    data, error);
290
+                logger.error('Failed to parse channel message as JSON: ', data, error);
301 291
 
302 292
                 return;
303 293
             }
@@ -309,41 +299,30 @@ export default class BridgeChannel {
309 299
                 // Endpoint ID from the Videobridge.
310 300
                 const dominantSpeakerEndpoint = obj.dominantSpeakerEndpoint;
311 301
 
312
-                logger.info(
313
-                    'Channel new dominant speaker event: ',
314
-                    dominantSpeakerEndpoint);
315
-                emitter.emit(
316
-                    RTCEvents.DOMINANT_SPEAKER_CHANGED,
317
-                    dominantSpeakerEndpoint);
302
+                logger.info(`New dominant speaker: ${dominantSpeakerEndpoint}.`);
303
+                emitter.emit(RTCEvents.DOMINANT_SPEAKER_CHANGED, dominantSpeakerEndpoint);
318 304
                 break;
319 305
             }
320 306
             case 'EndpointConnectivityStatusChangeEvent': {
321 307
                 const endpoint = obj.endpoint;
322 308
                 const isActive = obj.active === 'true';
323 309
 
324
-                logger.info(
325
-                    `Endpoint connection status changed: ${endpoint} active ? ${
326
-                        isActive}`);
327
-                emitter.emit(RTCEvents.ENDPOINT_CONN_STATUS_CHANGED,
328
-                    endpoint, isActive);
310
+                logger.info(`Endpoint connection status changed: ${endpoint} active=${isActive}`);
311
+                emitter.emit(RTCEvents.ENDPOINT_CONN_STATUS_CHANGED, endpoint, isActive);
329 312
 
330 313
                 break;
331 314
             }
332 315
             case 'EndpointMessage': {
333
-                emitter.emit(
334
-                    RTCEvents.ENDPOINT_MESSAGE_RECEIVED, obj.from,
335
-                    obj.msgPayload);
316
+                emitter.emit(RTCEvents.ENDPOINT_MESSAGE_RECEIVED, obj.from, obj.msgPayload);
336 317
 
337 318
                 break;
338 319
             }
339 320
             case 'LastNEndpointsChangeEvent': {
340
-                // The new/latest list of last-n endpoint IDs.
321
+                // The new/latest list of last-n endpoint IDs (i.e. endpoints for which the bridge is sending video).
341 322
                 const lastNEndpoints = obj.lastNEndpoints;
342 323
 
343
-                logger.info('Channel new last-n event: ',
344
-                    lastNEndpoints, obj);
345
-                emitter.emit(RTCEvents.LASTN_ENDPOINT_CHANGED,
346
-                    lastNEndpoints, obj);
324
+                logger.info(`New forwarded endpoints: ${lastNEndpoints}`);
325
+                emitter.emit(RTCEvents.LASTN_ENDPOINT_CHANGED, lastNEndpoints);
347 326
 
348 327
                 break;
349 328
             }

Ładowanie…
Anuluj
Zapisz