Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat: add logging config
paweldomas76c89845a8eb
diff --git a/app.js b/app.jsindex cfec93da20..7996f208e8 100644--- a/app.js+++ b/app.js@@ -1,4 +1,4 @@-/* global $, config, getRoomName */+/* global $, config, getRoomName, loggingConfig, JitsiMeetJS *//* application specific logic */const logger = require("jitsi-meet-logger").getLogger(__filename);@@ -19,6 +19,8 @@ import 'aui-experimental-css';window.toastr = require("toastr");+const Logger = require("jitsi-meet-logger");+import URLProcessor from "./modules/config/URLProcessor";import RoomnameGenerator from './modules/util/RoomnameGenerator';@@ -32,6 +34,7 @@ import UIEvents from './service/UI/UIEvents';import getTokenData from "./modules/tokendata/TokenData";import translation from "./modules/translation/translation";+/*** Tries to push history state with the following parameters:* 'VideoChat', `Room: ${roomName}`, URL. If fail, prints the error and returns@@ -79,6 +82,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",@@ -107,6 +140,7 @@ const APP = {connection: null,API,init () {+ configureLoggingLevels();this.keyboardshortcut =require("./modules/keyboardshortcut/keyboardshortcut");this.configFetch = require("./modules/config/HttpConfigFetch");diff --git a/conference.js b/conference.jsindex 6e084e6824..992d0ef35d 100644--- a/conference.js+++ b/conference.js@@ -464,8 +464,6 @@ export default {*/init(options) {this.roomName = options.roomName;- JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);-// attaches global error handler, if there is already one, respect itif(JitsiMeetJS.getGlobalOnErrorHandler){var oldOnErrorHandler = window.onerror;diff --git a/index.html b/index.htmlindex f24aeb54ee..4b475d9065 100644--- a/index.html+++ b/index.html@@ -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" -->diff --git a/logging_config.js b/logging_config.jsnew file mode 100644index 0000000000..00cefdf32d--- /dev/null+++ b/logging_config.js@@ -0,0 +1,8 @@+// Logging configuration+var loggingConfig = { // eslint-disable-line no-unused-vars+ //default log level for the app and lib-jitsi-meet+ //defaultLogLevel: 'trace',+ // Examples:+ //'modules/version/ComponentsVersions.js': 'info',+ //'modules/xmpp/ChatRoom.js': 'log'+};\ No newline at end of filediff --git a/modules/config/URLProcessor.js b/modules/config/URLProcessor.jsindex 125d6c1d46..35dfbf2e33 100644--- a/modules/config/URLProcessor.js+++ b/modules/config/URLProcessor.js@@ -1,4 +1,4 @@-/* global config, interfaceConfig, getConfigParamsFromUrl */+/* global config, interfaceConfig, loggingConfig, getConfigParamsFromUrl */const logger = require("jitsi-meet-logger").getLogger(__filename);var configUtils = require('./Util');@@ -27,7 +27,8 @@ var URLProcessor = {// }var configJSON = {config: {},- interfaceConfig: {}+ interfaceConfig: {},+ loggingConfig: {}};for (var key in params) {if (typeof key !== "string") {@@ -47,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)@@ -54,7 +58,8 @@ var URLProcessor = {confObj[confKey] = params[key];}- configUtils.overrideConfigJSON(config, interfaceConfig, configJSON);+ configUtils.overrideConfigJSON(+ config, interfaceConfig, loggingConfig, configJSON);}};diff --git a/modules/config/Util.js b/modules/config/Util.jsindex 29bf9e5999..7d7065f563 100644--- a/modules/config/Util.js+++ b/modules/config/Util.js@@ -7,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:* {@@ -14,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;@@ -26,6 +32,8 @@ var ConfigUtil = {confObj = config;} else if (configRoot == "interfaceConfig") {confObj = interfaceConfig;+ } else if (configRoot == "loggingConfig") {+ confObj = loggingConfig;} else {continue;}