feat: add logging config
This commit is contained in:
parent
b58f1cdd16
commit
76c89845a8
36
app.js
36
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");
|
||||
|
|
|
@ -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 it
|
||||
if(JitsiMeetJS.getGlobalOnErrorHandler){
|
||||
var oldOnErrorHandler = window.onerror;
|
||||
|
|
|
@ -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" -->
|
||||
|
|
|
@ -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'
|
||||
};
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue