Skip to content

Commit

Permalink
Use log modules in Erizo Client (#1592)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcague authored Jun 4, 2020
1 parent e71cec4 commit 1386403
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 190 deletions.
32 changes: 17 additions & 15 deletions erizo_controller/erizoClient/src/ErizoConnectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ const QUALITY_LEVELS = [
QUALITY_LEVEL_GOOD,
];

const log = Logger.module('ErizoConnection');

class ErizoConnection extends EventEmitterConst {
constructor(specInput, erizoId = undefined) {
super();
Logger.debug('Building a new Connection');
log.debug('Building a new Connection');
this.stack = {};

this.erizoId = erizoId;
Expand All @@ -48,30 +50,30 @@ class ErizoConnection extends EventEmitterConst {
// Check which WebRTC Stack is installed.
this.browser = ConnectionHelpers.getBrowser();
if (this.browser === 'fake') {
Logger.warning('Publish/subscribe video/audio streams not supported in erizofc yet');
log.warning('Publish/subscribe video/audio streams not supported in erizofc yet');
this.stack = FcStack(spec);
} else if (this.browser === 'mozilla') {
Logger.debug('Firefox Stack');
log.debug('Firefox Stack');
this.stack = FirefoxStack(spec);
} else if (this.browser === 'safari') {
Logger.debug('Safari using Chrome Stable Stack');
log.debug('Safari using Chrome Stable Stack');
this.stack = ChromeStableStack(spec);
} else if (this.browser === 'chrome-stable' || this.browser === 'electron') {
Logger.debug('Chrome Stable Stack');
log.debug('Chrome Stable Stack');
this.stack = ChromeStableStack(spec);
} else {
Logger.error('No stack available for this browser');
log.error('No stack available for this browser');
throw new Error('WebRTC stack not available');
}
if (!this.stack.updateSpec) {
this.stack.updateSpec = (newSpec, callback = () => {}) => {
Logger.error('Update Configuration not implemented in this browser');
log.error('Update Configuration not implemented in this browser');
callback('unimplemented');
};
}
if (!this.stack.setSignallingCallback) {
this.stack.setSignallingCallback = () => {
Logger.error('setSignallingCallback is not implemented in this stack');
log.error('setSignallingCallback is not implemented in this stack');
};
}

Expand All @@ -95,7 +97,7 @@ class ErizoConnection extends EventEmitterConst {
}

close() {
Logger.debug('Closing ErizoConnection');
log.debug('Closing ErizoConnection');
this.streamsMap.clear();
this.stack.close();
}
Expand All @@ -109,7 +111,7 @@ class ErizoConnection extends EventEmitterConst {
}

addStream(stream) {
Logger.debug(`message: Adding stream to Connection, streamId: ${stream.getID()}`);
log.debug(`message: Adding stream to Connection, streamId: ${stream.getID()}`);
this.streamsMap.add(stream.getID(), stream);
if (stream.local) {
this.stack.addStream(stream.stream);
Expand All @@ -119,7 +121,7 @@ class ErizoConnection extends EventEmitterConst {
removeStream(stream) {
const streamId = stream.getID();
if (!this.streamsMap.has(streamId)) {
Logger.debug(`message: Cannot remove stream not in map, streamId: ${streamId}`);
log.debug(`message: Cannot remove stream not in map, streamId: ${streamId}`);
return;
}
this.streamsMap.remove(streamId);
Expand Down Expand Up @@ -185,7 +187,7 @@ class ErizoConnectionManager {
}

getOrBuildErizoConnection(specInput, erizoId = undefined, singlePC = false) {
Logger.debug(`message: getOrBuildErizoConnection, erizoId: ${erizoId}`);
log.debug(`message: getOrBuildErizoConnection, erizoId: ${erizoId}`);
let connection = {};

if (erizoId === undefined) {
Expand Down Expand Up @@ -228,12 +230,12 @@ class ErizoConnectionManager {
}

maybeCloseConnection(connection, force = false) {
Logger.debug(`Trying to remove connection ${connection.sessionId}
log.debug(`Trying to remove connection ${connection.sessionId}
with erizoId ${connection.erizoId}`);
if (connection.streamsMap.size() === 0 || force) {
Logger.debug(`No streams in connection ${connection.sessionId}, erizoId: ${connection.erizoId}`);
log.debug(`No streams in connection ${connection.sessionId}, erizoId: ${connection.erizoId}`);
if (this.ErizoConnectionsMap.get(connection.erizoId) !== undefined && this.ErizoConnectionsMap.get(connection.erizoId)['single-pc'] && !force) {
Logger.debug(`Will not remove empty connection ${connection.erizoId} - it is singlePC`);
log.debug(`Will not remove empty connection ${connection.erizoId} - it is singlePC`);
return;
}
connection.close();
Expand Down
3 changes: 2 additions & 1 deletion erizo_controller/erizoClient/src/Events.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global */
import Logger from './utils/Logger';

const log = Logger.module('EventDispatcher');
/*
* Class EventDispatcher provides event handling to sub-classes.
* It is inherited from Publisher, Room, etc.
Expand Down Expand Up @@ -50,7 +51,7 @@ const EventDispatcher = () => {
try {
listeners[i](event);
} catch (e) {
Logger.info(`Error triggering event: ${event.type}, error: ${e}`);
log.info(`Error triggering event: ${event.type}, error: ${e}`);
}
}
};
Expand Down
Loading

0 comments on commit 1386403

Please sign in to comment.