Merge pull request #1158 from jitsi/log_collector

Log collector
This commit is contained in:
hristoterezov 2016-11-30 13:07:18 -06:00 committed by GitHub
commit 8745efb81f
33 changed files with 354 additions and 117 deletions

108
app.js
View File

@ -1,5 +1,6 @@
/* global $, config, getRoomName */
/* global $, config, getRoomName, loggingConfig, JitsiMeetJS */
/* application specific logic */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import "babel-polyfill";
import "jquery";
@ -18,6 +19,10 @@ import 'aui-experimental-css';
window.toastr = require("toastr");
const Logger = require("jitsi-meet-logger");
const LogCollector = Logger.LogCollector;
import JitsiMeetLogStorage from "./modules/util/JitsiMeetLogStorage";
import URLProcessor from "./modules/config/URLProcessor";
import RoomnameGenerator from './modules/util/RoomnameGenerator';
@ -31,6 +36,8 @@ import UIEvents from './service/UI/UIEvents';
import getTokenData from "./modules/tokendata/TokenData";
import translation from "./modules/translation/translation";
const ConferenceEvents = JitsiMeetJS.events.conference;
/**
* Tries to push history state with the following parameters:
* 'VideoChat', `Room: ${roomName}`, URL. If fail, prints the error and returns
@ -42,7 +49,7 @@ function pushHistoryState(roomName, URL) {
'VideoChat', `Room: ${roomName}`, URL
);
} catch (e) {
console.warn("Push history state failed with parameters:",
logger.warn("Push history state failed with parameters:",
'VideoChat', `Room: ${roomName}`, URL, e);
return e;
}
@ -78,6 +85,36 @@ function buildRoomName () {
return roomName;
}
/**
* Adjusts the logging levels.
* @private
*/
function configureLoggingLevels () {
// NOTE The library Logger is separated from the app loggers, so the levels
// have to be set in two places
// Set default logging level
const defaultLogLevel
= loggingConfig.defaultLogLevel || JitsiMeetJS.logLevels.TRACE;
Logger.setLogLevel(defaultLogLevel);
JitsiMeetJS.setLogLevel(defaultLogLevel);
// NOTE console was used on purpose here to go around the logging
// and always print the default logging level to the console
console.info("Default logging level set to: " + defaultLogLevel);
// Set log level for each logger
if (loggingConfig) {
Object.keys(loggingConfig).forEach(function(loggerName) {
if ('defaultLogLevel' !== loggerName) {
const level = loggingConfig[loggerName];
Logger.setLogLevelById(level, loggerName);
JitsiMeetJS.setLogLevelById(level, loggerName);
}
});
}
}
const APP = {
// Used by do_external_connect.js if we receive the attach data after
// connect was already executed. status property can be "initialized",
@ -97,6 +134,16 @@ const APP = {
settings,
conference,
translation,
/**
* The log collector which captures JS console logs for this app.
* @type {LogCollector}
*/
logCollector: null,
/**
* Indicates if the log collector has been started (it will not be started
* if the welcome page is displayed).
*/
logCollectorStarted : false,
/**
* After the APP has been initialized provides utility methods for dealing
* with the conference room URL(address).
@ -106,10 +153,24 @@ const APP = {
connection: null,
API,
init () {
this.initLogging();
this.keyboardshortcut =
require("./modules/keyboardshortcut/keyboardshortcut");
this.configFetch = require("./modules/config/HttpConfigFetch");
this.tokenData = getTokenData();
},
initLogging () {
// Adjust logging level
configureLoggingLevels();
// Create the LogCollector and register it as the global log transport.
// It is done early to capture as much logs as possible. Captured logs
// will be cached, before the JitsiMeetLogStorage gets ready (statistics
// module is initialized).
if (!this.logCollector && !loggingConfig.disableLogCollector) {
this.logCollector = new LogCollector(new JitsiMeetLogStorage());
Logger.addGlobalTransport(this.logCollector);
JitsiMeetJS.addGlobalLogTransport(this.logCollector);
}
}
};
@ -131,9 +192,39 @@ function init() {
APP.ConferenceUrl = new ConferenceUrl(window.location);
// Clean up the URL displayed by the browser
replaceHistoryState(APP.ConferenceUrl.getInviteUrl());
var isUIReady = APP.UI.start();
const isUIReady = APP.UI.start();
if (isUIReady) {
APP.conference.init({roomName: buildRoomName()}).then(function () {
if (APP.logCollector) {
// Start the LogCollector's periodic "store logs" task only if
// we're in the conference and not on the welcome page. This is
// determined by the value of "isUIReady" const above.
APP.logCollector.start();
APP.logCollectorStarted = true;
// Make an attempt to flush in case a lot of logs have been
// cached, before the collector was started.
APP.logCollector.flush();
// This event listener will flush the logs, before
// the statistics module (CallStats) is stopped.
//
// NOTE The LogCollector is not stopped, because this event can
// be triggered multiple times during single conference
// (whenever statistics module is stopped). That includes
// the case when Jicofo terminates the single person left in the
// room. It will then restart the media session when someone
// eventually join the room which will start the stats again.
APP.conference.addConferenceListener(
ConferenceEvents.BEFORE_STATISTICS_DISPOSED,
() => {
if (APP.logCollector) {
APP.logCollector.flush();
}
}
);
}
APP.UI.initConference();
APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {
@ -145,7 +236,7 @@ function init() {
}).catch(function (err) {
APP.UI.hideRingOverLay();
APP.API.notifyConferenceLeft(APP.conference.roomName);
console.error(err);
logger.error(err);
});
}
}
@ -169,7 +260,7 @@ function obtainConfigAndInit() {
if (success) {
var now = APP.connectionTimes["configuration.fetched"] =
window.performance.now();
console.log("(TIME) configuration fetched:\t", now);
logger.log("(TIME) configuration fetched:\t", now);
init();
} else {
// Show obtain config error,
@ -189,7 +280,7 @@ function obtainConfigAndInit() {
$(document).ready(function () {
var now = APP.connectionTimes["document.ready"] = window.performance.now();
console.log("(TIME) document ready:\t", now);
logger.log("(TIME) document ready:\t", now);
URLProcessor.setConfigParametersFromUrl();
@ -211,6 +302,11 @@ $(document).ready(function () {
});
$(window).bind('beforeunload', function () {
// Stop the LogCollector
if (APP.logCollectorStarted) {
APP.logCollector.stop();
APP.logCollectorStarted = false;
}
APP.API.dispose();
});

View File

@ -1,4 +1,6 @@
/* global $, APP, JitsiMeetJS, config, interfaceConfig */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import {openConnection} from './connection';
import Invite from './modules/UI/invite/Invite';
import ContactList from './modules/UI/side_pannels/contactlist/ContactList';
@ -166,7 +168,7 @@ function muteLocalMedia(localMedia, muted, localMediaTypeString) {
const method = muted ? 'mute' : 'unmute';
localMedia[method]().catch(reason => {
console.warn(`${localMediaTypeString} ${method} was rejected:`, reason);
logger.warn(`${localMediaTypeString} ${method} was rejected:`, reason);
});
}
@ -254,7 +256,7 @@ function createLocalTracks (options, checkForPermissionPrompt) {
});
return tracks;
}).catch(function (err) {
console.error(
logger.error(
'failed to create local tracks', options.devices, err);
return Promise.reject(err);
});
@ -311,7 +313,7 @@ class ConferenceConnector {
this._reject(err);
}
_onConferenceFailed(err, ...params) {
console.error('CONFERENCE FAILED:', err, ...params);
logger.error('CONFERENCE FAILED:', err, ...params);
APP.UI.hideRingOverLay();
switch (err) {
// room is locked by the password
@ -400,7 +402,7 @@ class ConferenceConnector {
}
}
_onConferenceError(err, ...params) {
console.error('CONFERENCE Error:', err, params);
logger.error('CONFERENCE Error:', err, params);
switch (err) {
case ConferenceErrors.CHAT_ERROR:
{
@ -409,7 +411,7 @@ class ConferenceConnector {
}
break;
default:
console.error("Unknown error.");
logger.error("Unknown error.", err);
}
}
_unsubscribe() {
@ -464,8 +466,6 @@ export default {
*/
init(options) {
this.roomName = options.roomName;
JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
// attaches global error handler, if there is already one, respect it
if(JitsiMeetJS.getGlobalOnErrorHandler){
var oldOnErrorHandler = window.onerror;
@ -495,7 +495,7 @@ export default {
analytics.init();
return createInitialLocalTracksAndConnect(options.roomName);
}).then(([tracks, con]) => {
console.log('initialized with %s local tracks', tracks.length);
logger.log('initialized with %s local tracks', tracks.length);
APP.connection = connection = con;
this._bindConnectionFailedHandler(con);
this._createRoom(tracks);
@ -549,7 +549,7 @@ export default {
// - item-not-found
// - connection dropped(closed by Strophe unexpectedly
// possible due too many transport errors)
console.error("XMPP connection error: " + errMsg);
logger.error("XMPP connection error: " + errMsg);
APP.UI.showPageReloadOverlay();
connection.removeEventListener(
ConnectionEvents.CONNECTION_FAILED, handler);
@ -879,7 +879,7 @@ export default {
} else if (track.isVideoTrack()) {
return this.useVideoStream(track);
} else {
console.error(
logger.error(
"Ignored not an audio nor a video track: ", track);
return Promise.resolve();
}
@ -971,11 +971,11 @@ export default {
videoSwitchInProgress: false,
toggleScreenSharing (shareScreen = !this.isSharingScreen) {
if (this.videoSwitchInProgress) {
console.warn("Switch in progress.");
logger.warn("Switch in progress.");
return;
}
if (!this.isDesktopSharingEnabled) {
console.warn("Cannot toggle screen sharing: not supported.");
logger.warn("Cannot toggle screen sharing: not supported.");
return;
}
@ -1029,7 +1029,7 @@ export default {
this.videoSwitchInProgress = false;
JitsiMeetJS.analytics.sendEvent(
'conference.sharingDesktop.start');
console.log('sharing local desktop');
logger.log('sharing local desktop');
}).catch((err) => {
// close external installation dialog to show the error.
if(externalInstallation)
@ -1041,7 +1041,7 @@ export default {
return;
}
console.error('failed to share local desktop', err);
logger.error('failed to share local desktop', err);
if (err.name === TrackErrors.FIREFOX_EXTENSION_NEEDED) {
APP.UI.showExtensionRequiredDialog(
@ -1078,11 +1078,11 @@ export default {
this.videoSwitchInProgress = false;
JitsiMeetJS.analytics.sendEvent(
'conference.sharingDesktop.stop');
console.log('sharing local video');
logger.log('sharing local video');
}).catch((err) => {
this.useVideoStream(null);
this.videoSwitchInProgress = false;
console.error('failed to share local video', err);
logger.error('failed to share local video', err);
});
}
},
@ -1108,7 +1108,7 @@ export default {
if (user.isHidden())
return;
console.log('USER %s connnected', id, user);
logger.log('USER %s connnected', id, user);
APP.API.notifyUserJoined(id);
APP.UI.addUser(user);
@ -1116,7 +1116,7 @@ export default {
APP.UI.updateUserRole(user);
});
room.on(ConferenceEvents.USER_LEFT, (id, user) => {
console.log('USER %s LEFT', id, user);
logger.log('USER %s LEFT', id, user);
APP.API.notifyUserLeft(id);
APP.UI.removeUser(id, user.getDisplayName());
APP.UI.onSharedVideoStop(id);
@ -1125,7 +1125,7 @@ export default {
room.on(ConferenceEvents.USER_ROLE_CHANGED, (id, role) => {
if (this.isLocalId(id)) {
console.info(`My role changed, new role: ${role}`);
logger.info(`My role changed, new role: ${role}`);
if (this.isModerator !== room.isModerator()) {
this.isModerator = room.isModerator();
APP.UI.updateLocalRole(room.isModerator());
@ -1183,7 +1183,7 @@ export default {
{
this.audioLevelsMap[id] = lvl;
if(config.debugAudioLevels)
console.log("AudioLevel:" + id + "/" + lvl);
logger.log("AudioLevel:" + id + "/" + lvl);
}
APP.UI.setAudioLevel(id, lvl);
@ -1264,7 +1264,7 @@ export default {
});
room.on(ConferenceEvents.RECORDER_STATE_CHANGED, (status, error) => {
console.log("Received recorder status change: ", status, error);
logger.log("Received recorder status change: ", status, error);
APP.UI.updateRecordingState(status);
});
@ -1500,7 +1500,7 @@ export default {
})
.then(([stream]) => {
this.useVideoStream(stream);
console.log('switched local video device');
logger.log('switched local video device');
APP.settings.setCameraDeviceId(cameraDeviceId, true);
})
.catch((err) => {
@ -1522,7 +1522,7 @@ export default {
})
.then(([stream]) => {
this.useAudioStream(stream);
console.log('switched local audio device');
logger.log('switched local audio device');
APP.settings.setMicDeviceId(micDeviceId, true);
})
.catch((err) => {
@ -1538,9 +1538,9 @@ export default {
JitsiMeetJS.analytics.sendEvent(
'settings.changeDevice.audioOut');
APP.settings.setAudioOutputDeviceId(audioOutputDeviceId)
.then(() => console.log('changed audio output device'))
.then(() => logger.log('changed audio output device'))
.catch((err) => {
console.warn('Failed to change audio output device. ' +
logger.warn('Failed to change audio output device. ' +
'Default or previously set audio output device ' +
'will be used instead.', err);
APP.UI.setSelectedAudioOutputFromSettings();
@ -1746,6 +1746,15 @@ export default {
room.sendApplicationLog(JSON.stringify({name, value}));
}
},
/**
* Methods logs an application event given in the JSON format.
* @param {string} logJSON an event to be logged in JSON format
*/
logJSON(logJSON) {
if (room) {
room.sendApplicationLog(logJSON);
}
},
/**
* Disconnect from the conference and optionally request user feedback.
* @param {boolean} [requestFeedback=false] if user feedback should be

View File

@ -1,4 +1,6 @@
/* global APP, JitsiMeetJS, config */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import AuthHandler from './modules/UI/authentication/AuthHandler';
import jitsiLocalStorage from './modules/util/JitsiLocalStorage';
@ -84,7 +86,7 @@ function connect(id, password, roomName) {
function handleConnectionFailed(err) {
unsubscribe();
console.error("CONNECTION FAILED:", err);
logger.error("CONNECTION FAILED:", err);
reject(err);
}

View File

@ -14,6 +14,7 @@
"utils.js",
"do_external_connect.js",
"interface_config.js",
"logging_config.js",
"lib-jitsi-meet.min.js",
"app.bundle.min.js",
"all.css"
@ -43,6 +44,7 @@
<!--#include virtual="connection_optimization/connection_optimization.html" -->
<script src="connection_optimization/do_external_connect.js?v=1"></script>
<script><!--#include virtual="/interface_config.js" --></script>
<script><!--#include virtual="/logging_config.js" --></script>
<script src="libs/lib-jitsi-meet.min.js?v=139"></script>
<script src="libs/app.bundle.min.js?v=139"></script>
<!--#include virtual="title.html" -->

10
logging_config.js Normal file
View File

@ -0,0 +1,10 @@
// Logging configuration
var loggingConfig = { // eslint-disable-line no-unused-vars
//default log level for the app and lib-jitsi-meet
//defaultLogLevel: 'trace',
// Option to disable LogCollector (which stores the logs on CallStats)
//disableLogCollector: true,
// Examples:
//'modules/version/ComponentsVersions.js': 'info',
//'modules/xmpp/ChatRoom.js': 'log'
};

View File

@ -1,4 +1,6 @@
/* global APP, getConfigParamsFromUrl */
const logger = require("jitsi-meet-logger").getLogger(__filename);
/**
* Implements API class that communicates with external api class
* and provides interface to access Jitsi Meet features by external
@ -131,13 +133,13 @@ function onSystemMessage(message) {
switch (message.type) {
case "eventStatus":
if(!message.name || !message.value) {
console.warn("Unknown system message format", message);
logger.warn("Unknown system message format", message);
break;
}
events[message.name] = message.value;
break;
default:
console.warn("Unknown system message type", message);
logger.warn("Unknown system message type", message);
}
}

View File

@ -1,3 +1,5 @@
const logger = require("jitsi-meet-logger").getLogger(__filename);
/**
* Implements API class that embeds Jitsi Meet in external applications.
*/
@ -72,7 +74,7 @@ function sendMessage(postis, object) {
*/
function changeEventStatus(postis, event, status) {
if(!(event in events)) {
console.error("Not supported event name.");
logger.error("Not supported event name.");
return;
}
sendMessage(postis, {
@ -174,7 +176,7 @@ function JitsiMeetExternalAPI(domain, room_name, width, height, parentNode,
*/
JitsiMeetExternalAPI.prototype.executeCommand = function(name, argumentsList) {
if(!(name in commands)) {
console.error("Not supported command name.");
logger.error("Not supported command name.");
return;
}
var argumentsArray = argumentsList;
@ -306,7 +308,7 @@ JitsiMeetExternalAPI.prototype.addEventListeners = function(object) {
*/
JitsiMeetExternalAPI.prototype.addEventListener = function(event, listener) {
if(!(event in events)) {
console.error("Not supported event name.");
logger.error("Not supported event name.");
return;
}
// We cannot remove listeners from postis that's why we are handling the
@ -328,7 +330,7 @@ JitsiMeetExternalAPI.prototype.addEventListener = function(event, listener) {
JitsiMeetExternalAPI.prototype.removeEventListener = function(event) {
if(!(event in this.eventHandlers))
{
console.error("The event " + event + " is not registered.");
logger.error("The event " + event + " is not registered.");
return;
}
delete this.eventHandlers[event];

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const logger = require("jitsi-meet-logger").getLogger(__filename);
import UIEvents from '../service/UI/UIEvents';
import VideoLayout from './UI/videolayout/VideoLayout';
@ -308,7 +309,7 @@ class FollowMe {
if (!this._conference.isParticipantModerator(id))
{
console.warn('Received follow-me command ' +
logger.warn('Received follow-me command ' +
'not from moderator');
return;
}

View File

@ -1,4 +1,6 @@
/* global APP, JitsiMeetJS, $, config, interfaceConfig, toastr */
const logger = require("jitsi-meet-logger").getLogger(__filename);
var UI = {};
import Chat from "./side_pannels/chat/Chat";
@ -503,7 +505,7 @@ UI.addLocalStream = function (track) {
VideoLayout.changeLocalVideo(track);
break;
default:
console.error("Unknown stream type: " + track.getType());
logger.error("Unknown stream type: " + track.getType());
break;
}
};
@ -541,7 +543,7 @@ UI.initEtherpad = function (name) {
if (etherpadManager || !config.etherpad_base || !name) {
return;
}
console.log('Etherpad is enabled');
logger.log('Etherpad is enabled');
etherpadManager
= new EtherpadManager(config.etherpad_base, name, eventEmitter);
Toolbar.showEtherpadButton();
@ -739,7 +741,7 @@ UI.connectionIndicatorShowMore = function(id) {
// FIXME check if someone user this
UI.showLoginPopup = function(callback) {
console.log('password is required');
logger.log('password is required');
let message = (
`<input name="username" type="text"

View File

@ -1,4 +1,5 @@
/* global APP, config, JitsiMeetJS, Promise */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import LoginDialog from './LoginDialog';
import UIUtil from '../util/UIUtil';
@ -74,13 +75,13 @@ function redirectToTokenAuthService(roomName) {
function initJWTTokenListener(room) {
var listener = function (event) {
if (externalAuthWindow !== event.source) {
console.warn("Ignored message not coming " +
logger.warn("Ignored message not coming " +
"from external authnetication window");
return;
}
if (event.data && event.data.jwtToken) {
config.token = event.data.jwtToken;
console.info("Received JWT token:", config.token);
logger.info("Received JWT token:", config.token);
var roomName = room.getName();
openConnection({retry: false, roomName: roomName })
.then(function (connection) {
@ -97,10 +98,10 @@ function initJWTTokenListener(room) {
// to upgrade user's role
room.room.moderator.authenticate()
.then(function () {
console.info("User role upgrade done !");
logger.info("User role upgrade done !");
unregister();
}).catch(function (err, errCode) {
console.error(
logger.error(
"Authentication failed: ", err, errCode);
unregister();
}
@ -108,13 +109,13 @@ function initJWTTokenListener(room) {
}).catch(function (error, code) {
unregister();
connection.disconnect();
console.error(
logger.error(
'Authentication failed on the new connection',
error, code);
});
}, function (err) {
unregister();
console.error("Failed to open new connection", err);
logger.error("Failed to open new connection", err);
});
}
};
@ -161,7 +162,7 @@ function doXmppAuth (room, lockPassword) {
}).catch(function (error, code) {
connection.disconnect();
console.error('Auth on the fly failed', error);
logger.error('Auth on the fly failed', error);
loginDialog.displayError(
'connection.GET_SESSION_ID_ERROR', {code: code});

View File

@ -22,6 +22,7 @@
*/
/* global MD5, config, interfaceConfig, APP */
const logger = require("jitsi-meet-logger").getLogger(__filename);
let users = {};
@ -110,7 +111,7 @@ export default {
let random = !avatarId || avatarId.indexOf('@') < 0;
if (!avatarId) {
console.warn(
logger.warn(
`No avatar stored yet for ${userId} - using ID as avatar ID`);
avatarId = userId;
}

View File

@ -1,4 +1,5 @@
/* global JitsiMeetJS, APP */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import InviteDialogView from './InviteDialogView';
import createRoomLocker from './RoomLocker';
@ -28,7 +29,7 @@ class Invite {
this.conference.on(ConferenceEvents.LOCK_STATE_CHANGED,
(locked, error) => {
console.log("Received channel password lock change: ", locked,
logger.log("Received channel password lock change: ", locked,
error);
if (!locked) {

View File

@ -1,4 +1,5 @@
/* global $, APP, JitsiMeetJS */
const logger = require("jitsi-meet-logger").getLogger(__filename);
/**
* Substate for password
@ -312,7 +313,7 @@ export default class InviteDialogView {
this.blur();
}
catch (err) {
console.error('error when copy the text');
logger.error('error when copy the text');
}
}
});

View File

@ -1,4 +1,6 @@
/* global APP, JitsiMeetJS */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import RequirePasswordDialog from './RequirePasswordDialog';
/**
@ -6,7 +8,7 @@ import RequirePasswordDialog from './RequirePasswordDialog';
* because server doesn't support that.
*/
function notifyPasswordNotSupported () {
console.warn('room passwords not supported');
logger.warn('room passwords not supported');
APP.UI.messageHandler.showError(
"dialog.warning", "dialog.passwordNotSupported");
}
@ -16,7 +18,7 @@ function notifyPasswordNotSupported () {
* @param {Error} err error
*/
function notifyPasswordFailed(err) {
console.warn('setting password failed', err);
logger.warn('setting password failed', err);
APP.UI.messageHandler.showError(
"dialog.lockTitle", "dialog.lockMessage");
}
@ -64,7 +66,7 @@ export default function createRoomLocker (room) {
if (!password)
lockedElsewhere = false;
}).catch(function (err) {
console.error(err);
logger.error(err);
if (err === ConferenceErrors.PASSWORD_NOT_SUPPORTED) {
notifyPasswordNotSupported();
} else {
@ -113,7 +115,7 @@ export default function createRoomLocker (room) {
// pass stays between attempts
password = null;
if (reason !== APP.UI.messageHandler.CANCEL)
console.error(reason);
logger.error(reason);
}
);
},

View File

@ -14,6 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const logger = require("jitsi-meet-logger").getLogger(__filename);
import UIEvents from "../../../service/UI/UIEvents";
import UIUtil from '../util/UIUtil';
import VideoLayout from '../videolayout/VideoLayout';
@ -327,7 +329,7 @@ var Recording = {
}).catch(
reason => {
if (reason !== APP.UI.messageHandler.CANCEL)
console.error(reason);
logger.error(reason);
else
JitsiMeetJS.analytics.sendEvent(
'recording.canceled');
@ -350,7 +352,7 @@ var Recording = {
}).catch(
reason => {
if (reason !== APP.UI.messageHandler.CANCEL)
console.error(reason);
logger.error(reason);
else
JitsiMeetJS.analytics.sendEvent(
'recording.canceled');

View File

@ -1,4 +1,5 @@
/* global $, APP, AJS */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import Overlay from '../overlay/Overlay';
@ -84,7 +85,7 @@ class PageReloadOverlayImpl extends Overlay{
}
}.bind(this), 1000);
console.info(
logger.info(
"The conference will be reloaded after "
+ this.timeLeft + " seconds.");
}

View File

@ -1,5 +1,6 @@
/* global $, APP, YT, onPlayerReady, onPlayerStateChange, onPlayerError,
JitsiMeetJS */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import UIUtil from '../util/UIUtil';
import UIEvents from '../../../service/UI/UIEvents';
@ -75,7 +76,7 @@ export default class SharedVideoManager {
JitsiMeetJS.analytics.sendEvent('sharedvideo.started');
},
err => {
console.log('SHARED VIDEO CANCELED', err);
logger.log('SHARED VIDEO CANCELED', err);
JitsiMeetJS.analytics.sendEvent('sharedvideo.canceled');
}
);
@ -277,7 +278,7 @@ export default class SharedVideoManager {
};
window.onPlayerError = function(event) {
console.error("Error in the player:", event.data);
logger.error("Error in the player:", event.data);
// store the error player, so we can remove it
self.errorInPlayer = event.target;
};
@ -313,7 +314,7 @@ export default class SharedVideoManager {
&& player.getVolume() != attributes.volume) {
player.setVolume(attributes.volume);
console.info("Player change of volume:" + attributes.volume);
logger.info("Player change of volume:" + attributes.volume);
this.showSharedVideoMutedPopup(false);
}
@ -337,7 +338,7 @@ export default class SharedVideoManager {
processTime (player, attributes, forceSeek)
{
if(forceSeek) {
console.info("Player seekTo:", attributes.time);
logger.info("Player seekTo:", attributes.time);
player.seekTo(attributes.time);
return;
}
@ -349,7 +350,7 @@ export default class SharedVideoManager {
// if we drift more than the interval for checking
// sync, the interval is in milliseconds
if(diff > updateInterval/1000) {
console.info("Player seekTo:", attributes.time,
logger.info("Player seekTo:", attributes.time,
" current time is:", currentPosition, " diff:", diff);
player.seekTo(attributes.time);
}
@ -669,7 +670,7 @@ SharedVideoThumb.prototype.videoClick = function () {
* Removes RemoteVideo from the page.
*/
SharedVideoThumb.prototype.remove = function () {
console.log("Remove shared video thumb", this.id);
logger.log("Remove shared video thumb", this.id);
// Make sure that the large video is updated if are removing its
// corresponding small video.
@ -686,7 +687,7 @@ SharedVideoThumb.prototype.remove = function () {
*/
SharedVideoThumb.prototype.setDisplayName = function(displayName) {
if (!this.container) {
console.warn( "Unable to set displayName - " + this.videoSpanId +
logger.warn( "Unable to set displayName - " + this.videoSpanId +
" does not exist");
return;
}

View File

@ -1,4 +1,6 @@
/* global $, APP, interfaceConfig */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import Avatar from '../../avatar/Avatar';
import UIEvents from '../../../../service/UI/UIEvents';
import UIUtil from '../../util/UIUtil';
@ -27,7 +29,7 @@ function updateNumberOfParticipants(delta) {
numberOfContacts += delta;
if (numberOfContacts <= 0) {
console.error("Invalid number of participants: " + numberOfContacts);
logger.error("Invalid number of participants: " + numberOfContacts);
return;
}

View File

@ -1,4 +1,5 @@
/* global $, APP, toastr */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import UIUtil from './UIUtil';
import jitsiLocalStorage from '../../util/JitsiLocalStorage';
@ -79,7 +80,7 @@ function dontShowTheDialog(options) {
function dontShowAgainSubmitFunctionWrapper(options, submitFunction) {
if(isDontShowAgainEnabled(options)) {
return (...args) => {
console.debug(args, options.buttonValues);
logger.debug(args, options.buttonValues);
//args[1] is the value associated with the pressed button
if(!options.buttonValues || options.buttonValues.length === 0
|| options.buttonValues.indexOf(args[1]) !== -1 ) {
@ -417,7 +418,7 @@ var messageHandler = {
*/
openReportDialog: function(titleKey, msgKey, error) {
this.openMessageDialog(titleKey, msgKey);
console.log(error);
logger.log(error);
//FIXME send the error to the server
},

View File

@ -1,4 +1,5 @@
/* global $, APP, interfaceConfig */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import Avatar from "../avatar/Avatar";
import {createDeferred} from '../../util/helpers';
@ -126,7 +127,7 @@ export default class LargeVideoManager {
const { id, stream, videoType, resolve } = this.newStreamData;
this.newStreamData = null;
console.info("hover in %s", id);
logger.info("hover in %s", id);
this.state = videoType;
const container = this.getContainer(this.state);
container.setStream(stream, videoType);

View File

@ -1,4 +1,6 @@
/* global $, config, interfaceConfig, APP, JitsiMeetJS */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import ConnectionIndicator from "./ConnectionIndicator";
import UIUtil from "../util/UIUtil";
import UIEvents from "../../../service/UI/UIEvents";
@ -40,7 +42,7 @@ LocalVideo.prototype.constructor = LocalVideo;
*/
LocalVideo.prototype.setDisplayName = function(displayName) {
if (!this.container) {
console.warn(
logger.warn(
"Unable to set displayName - " + this.videoSpanId +
" does not exist");
return;

View File

@ -1,4 +1,5 @@
/* global $, APP, interfaceConfig */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import ConnectionIndicator from './ConnectionIndicator';
@ -191,7 +192,7 @@ RemoteVideo.prototype._muteHandler = function () {
}
}).catch(e => {
//currently shouldn't be called
console.error(e);
logger.error(e);
});
this.popover.forceHide();
@ -343,7 +344,7 @@ RemoteVideo.prototype.removeRemoteStreamElement = function (stream) {
this.wasVideoPlayed = false;
}
console.info((isVideo ? "Video" : "Audio") +
logger.info((isVideo ? "Video" : "Audio") +
" removed " + this.id, select);
// when removing only the video element and we are on stage
@ -408,7 +409,7 @@ RemoteVideo.prototype.updateConnectionStatusIndicator = function (isActive) {
}
}
console.debug(this.id + " thumbnail is connection active ? " + isActive);
logger.debug(this.id + " thumbnail is connection active ? " + isActive);
// Update 'mutedWhileDisconnected' flag
this._figureOutMutedWhileDisconnected(!isActive);
@ -427,7 +428,7 @@ RemoteVideo.prototype.updateConnectionStatusIndicator = function (isActive) {
* Removes RemoteVideo from the page.
*/
RemoteVideo.prototype.remove = function () {
console.log("Remove thumbnail", this.id);
logger.log("Remove thumbnail", this.id);
this.removeConnectionIndicator();
// Make sure that the large video is updated if are removing its
// corresponding small video.
@ -586,7 +587,7 @@ RemoteVideo.prototype.hideConnectionIndicator = function () {
*/
RemoteVideo.prototype.setDisplayName = function(displayName) {
if (!this.container) {
console.warn( "Unable to set displayName - " + this.videoSpanId +
logger.warn( "Unable to set displayName - " + this.videoSpanId +
" does not exist");
return;
}

View File

@ -1,4 +1,6 @@
/* global $, JitsiMeetJS, interfaceConfig */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import Avatar from "../avatar/Avatar";
import UIUtil from "../util/UIUtil";
import UIEvents from "../../../service/UI/UIEvents";
@ -497,7 +499,7 @@ SmallVideo.prototype.updateView = function () {
// Init avatar
this.avatarChanged(Avatar.getAvatarUrl(this.id));
} else {
console.error("Unable to init avatar - no id", this);
logger.error("Unable to init avatar - no id", this);
return;
}
}
@ -555,7 +557,7 @@ SmallVideo.prototype.showDominantSpeakerIndicator = function (show) {
return;
if (!this.container) {
console.warn( "Unable to set dominant speaker indicator - "
logger.warn( "Unable to set dominant speaker indicator - "
+ this.videoSpanId + " does not exist");
return;
}
@ -579,7 +581,7 @@ SmallVideo.prototype.showDominantSpeakerIndicator = function (show) {
*/
SmallVideo.prototype.showRaisedHandIndicator = function (show) {
if (!this.container) {
console.warn( "Unable to raised hand indication - "
logger.warn( "Unable to raised hand indication - "
+ this.videoSpanId + " does not exist");
return;
}

View File

@ -1,4 +1,5 @@
/* global config, APP, $, interfaceConfig */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import FilmStrip from "./FilmStrip";
import UIEvents from "../../../service/UI/UIEvents";
@ -261,19 +262,19 @@ var VideoLayout = {
if (lastVisible.length) {
let id = getPeerContainerResourceId(lastVisible[0]);
if (remoteVideos[id]) {
console.info("electLastVisibleVideo: " + id);
logger.info("electLastVisibleVideo: " + id);
return id;
}
// The RemoteVideo was removed (but the DOM elements may still
// exist).
}
console.info("Last visible video no longer exists");
logger.info("Last visible video no longer exists");
thumbs = FilmStrip.getThumbs().remoteThumbs;
if (thumbs.length) {
let id = getPeerContainerResourceId(thumbs[0]);
if (remoteVideos[id]) {
console.info("electLastVisibleVideo: " + id);
logger.info("electLastVisibleVideo: " + id);
return id;
}
// The RemoteVideo was removed (but the DOM elements may
@ -281,10 +282,10 @@ var VideoLayout = {
}
// Go with local video
console.info("Fallback to local video...");
logger.info("Fallback to local video...");
let id = APP.conference.getMyUserId();
console.info("electLastVisibleVideo: " + id);
logger.info("electLastVisibleVideo: " + id);
return id;
},
@ -438,7 +439,7 @@ var VideoLayout = {
// FIXME: what does this do???
remoteVideoActive(videoElement, resourceJid) {
console.info(resourceJid + " video is now active", videoElement);
logger.info(resourceJid + " video is now active", videoElement);
VideoLayout.resizeThumbnails(
false, false, function() {$(videoElement).show();});
@ -736,11 +737,11 @@ var VideoLayout = {
if (resourceJid &&
lastNEndpoints.indexOf(resourceJid) < 0 &&
localLastNSet.indexOf(resourceJid) < 0) {
console.log("Remove from last N", resourceJid);
logger.log("Remove from last N", resourceJid);
if (smallVideo)
smallVideo.showPeerContainer('hide');
else if (!APP.conference.isLocalId(resourceJid))
console.error("No remote video for: " + resourceJid);
logger.error("No remote video for: " + resourceJid);
isReceived = false;
} else if (resourceJid &&
//TOFIX: smallVideo may be undefined
@ -753,7 +754,7 @@ var VideoLayout = {
if (smallVideo)
smallVideo.showPeerContainer('avatar');
else if (!APP.conference.isLocalId(resourceJid))
console.error("No remote video for: " + resourceJid);
logger.error("No remote video for: " + resourceJid);
isReceived = false;
}
@ -780,7 +781,7 @@ var VideoLayout = {
remoteVideo.showPeerContainer('show');
if (!remoteVideo.isVisible()) {
console.log("Add to last N", resourceJid);
logger.log("Add to last N", resourceJid);
remoteVideo.addRemoteStreamElement(remoteVideo.videoStream);
@ -881,23 +882,23 @@ var VideoLayout = {
removeParticipantContainer (id) {
// Unlock large video
if (pinnedId === id) {
console.info("Focused video owner has left the conference");
logger.info("Focused video owner has left the conference");
pinnedId = null;
}
if (currentDominantSpeaker === id) {
console.info("Dominant speaker has left the conference");
logger.info("Dominant speaker has left the conference");
currentDominantSpeaker = null;
}
var remoteVideo = remoteVideos[id];
if (remoteVideo) {
// Remove remote video
console.info("Removing remote video: " + id);
logger.info("Removing remote video: " + id);
delete remoteVideos[id];
remoteVideo.remove();
} else {
console.warn("No remote video for " + id);
logger.warn("No remote video for " + id);
}
VideoLayout.resizeThumbnails();
@ -908,12 +909,12 @@ var VideoLayout = {
return;
}
console.info("Peer video type changed: ", id, newVideoType);
logger.info("Peer video type changed: ", id, newVideoType);
var smallVideo;
if (APP.conference.isLocalId(id)) {
if (!localVideoThumbnail) {
console.warn("Local video not ready yet");
logger.warn("Local video not ready yet");
return;
}
smallVideo = localVideoThumbnail;
@ -937,7 +938,7 @@ var VideoLayout = {
if (remoteVideo) {
remoteVideo.connectionIndicator.showMore();
} else {
console.info("Error - no remote video for id: " + id);
logger.info("Error - no remote video for id: " + id);
}
}
},
@ -994,7 +995,7 @@ var VideoLayout = {
if (smallVideo) {
smallVideo.avatarChanged(avatarUrl);
} else {
console.warn(
logger.warn(
"Missed avatar update - no small video yet for " + id
);
}

View File

@ -1,4 +1,4 @@
/* global console */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import { redirect } from '../util/helpers';
@ -45,8 +45,8 @@ export default class ConferenceUrl {
*/
this.inviteURL
= location.protocol + "//" + location.host + location.pathname;
console.info("Stored original conference URL: " + this.originalURL);
console.info("Conference URL for invites: " + this.inviteURL);
logger.info("Stored original conference URL: " + this.originalURL);
logger.info("Conference URL for invites: " + this.inviteURL);
}
/**
* Obtains the conference invite URL.
@ -67,7 +67,7 @@ export default class ConferenceUrl {
* Reloads the conference using original URL with all of the parameters.
*/
reload() {
console.info("Reloading the conference using URL: " + this.originalURL);
logger.info("Reloading the conference using URL: " + this.originalURL);
redirect(this.originalURL);
}
}

View File

@ -1,3 +1,5 @@
const logger = require("jitsi-meet-logger").getLogger(__filename);
var JSSHA = require('jssha');
module.exports = {
@ -22,7 +24,7 @@ module.exports = {
var attemptFirstAddress;
config.bosh = config.boshList[idx];
console.log('Setting config.bosh to ' + config.bosh +
logger.log('Setting config.bosh to ' + config.bosh +
' (idx=' + idx + ')');
if (config.boshAttemptFirstList &&
@ -34,10 +36,10 @@ module.exports = {
if (attemptFirstAddress != config.bosh) {
config.boshAttemptFirst = attemptFirstAddress;
console.log('Setting config.boshAttemptFirst=' +
logger.log('Setting config.boshAttemptFirst=' +
attemptFirstAddress + ' (idx=' + idx + ')');
} else {
console.log('Not setting boshAttemptFirst, address matches.');
logger.log('Not setting boshAttemptFirst, address matches.');
}
}
}

View File

@ -1,4 +1,5 @@
/* global $, config, interfaceConfig */
const logger = require("jitsi-meet-logger").getLogger(__filename);
var configUtil = require('./Util');
@ -16,7 +17,7 @@ var HttpConfig = {
* @param complete
*/
obtainConfig: function (endpoint, roomName, complete) {
console.info(
logger.info(
"Send config request to " + endpoint + " for room: " + roomName);
@ -28,7 +29,7 @@ var HttpConfig = {
data: JSON.stringify({"roomName": roomName}),
dataType: 'json',
error: function(jqXHR, textStatus, errorThrown) {
console.error("Get config error: ", jqXHR, errorThrown);
logger.error("Get config error: ", jqXHR, errorThrown);
var error = "Get config response status: " + textStatus;
complete(false, error);
},
@ -39,7 +40,7 @@ var HttpConfig = {
complete(true);
return;
} catch (exception) {
console.error("Parse config error: ", exception);
logger.error("Parse config error: ", exception);
complete(false, exception);
}
}

View File

@ -1,4 +1,6 @@
/* global config, interfaceConfig, getConfigParamsFromUrl */
/* global config, interfaceConfig, loggingConfig, getConfigParamsFromUrl */
const logger = require("jitsi-meet-logger").getLogger(__filename);
var configUtils = require('./Util');
var params = {};
@ -25,11 +27,12 @@ var URLProcessor = {
// }
var configJSON = {
config: {},
interfaceConfig: {}
interfaceConfig: {},
loggingConfig: {}
};
for (var key in params) {
if (typeof key !== "string") {
console.warn("Invalid config key: ", key);
logger.warn("Invalid config key: ", key);
continue;
}
var confObj = null, confKey;
@ -45,6 +48,9 @@ var URLProcessor = {
} else if (key.indexOf("interfaceConfig.") === 0) {
confObj = configJSON.interfaceConfig;
confKey = key.substr("interfaceConfig.".length);
} else if (key.indexOf("loggingConfig.") === 0) {
confObj = configJSON.loggingConfig;
confKey = key.substr("loggingConfig.".length);
}
if (!confObj)
@ -52,7 +58,8 @@ var URLProcessor = {
confObj[confKey] = params[key];
}
configUtils.overrideConfigJSON(config, interfaceConfig, configJSON);
configUtils.overrideConfigJSON(
config, interfaceConfig, loggingConfig, configJSON);
}
};

View File

@ -1,3 +1,5 @@
const logger = require("jitsi-meet-logger").getLogger(__filename);
var ConfigUtil = {
/**
* Method overrides JSON properties in <tt>config</tt> and
@ -5,6 +7,8 @@ var ConfigUtil = {
* @param config the config object for which we'll be overriding properties
* @param interfaceConfig the interfaceConfig object for which we'll be
* overriding properties.
* @param loggingConfig the logging config object for which we'll be
* overriding properties.
* @param newConfig object containing configuration properties. Destination
* object is selected based on root property name:
* {
@ -12,11 +16,15 @@ var ConfigUtil = {
* // config.js properties to be
* },
* interfaceConfig: {
* // interfaceConfig.js properties here
* // interface_config.js properties here
* },
* loggingConfig: {
* // logging_config.js properties here
* }
* }
*/
overrideConfigJSON: function (config, interfaceConfig, newConfig) {
overrideConfigJSON: function (config,
interfaceConfig, loggingConfig, newConfig) {
var configRoot, key, value, confObj;
for (configRoot in newConfig) {
confObj = null;
@ -24,6 +32,8 @@ var ConfigUtil = {
confObj = config;
} else if (configRoot == "interfaceConfig") {
confObj = interfaceConfig;
} else if (configRoot == "loggingConfig") {
confObj = loggingConfig;
} else {
continue;
}
@ -31,10 +41,10 @@ var ConfigUtil = {
for (key in newConfig[configRoot]) {
value = newConfig[configRoot][key];
if (confObj[key] && typeof confObj[key] !== typeof value) {
console.log("Overriding a " + configRoot +
logger.log("Overriding a " + configRoot +
" property with a property of different type.");
}
console.info("Overriding " + key + " with: " + value);
logger.info("Overriding " + key + " with: " + value);
confObj[key] = value;
}
}

View File

@ -1,4 +1,6 @@
/* global JitsiMeetJS */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import UIUtil from '../UI/util/UIUtil';
import jitsiLocalStorage from '../util/JitsiLocalStorage';
@ -37,7 +39,7 @@ if (audioOutputDeviceId !==
JitsiMeetJS.mediaDevices.getAudioOutputDevice()) {
JitsiMeetJS.mediaDevices.setAudioOutputDevice(audioOutputDeviceId)
.catch((ex) => {
console.warn('Failed to set audio output device from local ' +
logger.warn('Failed to set audio output device from local ' +
'storage. Default audio output device will be used' +
'instead.', ex);
});

View File

@ -0,0 +1,66 @@
/* global APP */
/**
* Implements logs storage through the CallStats.
*/
export default class JitsiMeetLogStorage {
/**
* Creates new <tt>JitsiMeetLogStorage</tt>
*/
constructor() {
/**
* Counts each log entry, increases on every batch log entry stored.
* @type {number}
*/
this.counter = 1;
}
/**
* @return {boolean} <tt>true</tt> when this storage is ready or
* <tt>false</tt> otherwise.
*/
isReady() {
return APP.logCollectorStarted && APP.conference;
}
/**
* Called by the <tt>LogCollector</tt> to store a series of log lines into
* batch.
* @param {string|object[]}logEntries an array containing strings
* representing log lines or aggregated lines objects.
*/
storeLogs(logEntries) {
if (!APP.conference.isCallstatsEnabled()) {
// Discard the logs if CallStats is not enabled.
return;
}
let logJSON = '{"log' + this.counter + '":"\n';
for (let i = 0, len = logEntries.length; i < len; i++) {
let logEntry = logEntries[i];
if (typeof logEntry === 'object') {
// Aggregated message
logJSON += '(' + logEntry.count + ') ' + logEntry.text + '\n';
} else {
// Regular message
logJSON += logEntry + '\n';
}
}
logJSON += '"}';
this.counter += 1;
// Try catch was used, because there are many variables
// on the way that could be uninitialized if the storeLogs
// attempt would be made very early (which is unlikely)
try {
APP.conference.logJSON(logJSON);
} catch (error) {
// NOTE console is intentional here
console.error(
"Failed to store the logs: ", logJSON, error);
}
}
}

View File

@ -1,3 +1,5 @@
const logger = require("jitsi-meet-logger").getLogger(__filename);
/**
* Create deferred object.
* @returns {{promise, resolve, reject}}
@ -35,7 +37,7 @@ export function redirect (url) {
* @param msg {string} [optional] the message printed in addition to the error
*/
export function reportError (e, msg = "") {
console.error(msg, e);
logger.error(msg, e);
if(window.onerror)
window.onerror(msg, null, null,
null, e);

View File

@ -22,6 +22,7 @@
"bootstrap": "3.1.1",
"i18next": "3.4.4",
"i18next-xhr-backend": "1.1.0",
"jitsi-meet-logger": "jitsi/jitsi-meet-logger",
"jquery": "~2.1.1",
"jquery-contextmenu": "*",
"jquery-i18next": "1.1.0",