You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.web.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* global APP, JitsiMeetJS, loggingConfig */
  2. import URLProcessor from '../../../modules/config/URLProcessor';
  3. import KeyboardShortcut
  4. from '../../../modules/keyboardshortcut/keyboardshortcut';
  5. import settings from '../../../modules/settings/Settings';
  6. import getTokenData from '../../../modules/tokendata/TokenData';
  7. import JitsiMeetLogStorage from '../../../modules/util/JitsiMeetLogStorage';
  8. const Logger = require('jitsi-meet-logger');
  9. export * from './functions.native';
  10. /**
  11. * Temporary solution. Later we'll get rid of global APP and set its properties
  12. * in redux store.
  13. *
  14. * @returns {void}
  15. */
  16. export function init() {
  17. URLProcessor.setConfigParametersFromUrl();
  18. _initLogging();
  19. APP.keyboardshortcut = KeyboardShortcut;
  20. APP.tokenData = getTokenData();
  21. APP.API.init(APP.tokenData.jwt ? {forceEnable: true} : undefined);
  22. APP.translation.init(settings.getLanguage());
  23. }
  24. /**
  25. * Adjusts the logging levels.
  26. *
  27. * @private
  28. * @returns {void}
  29. */
  30. function _configureLoggingLevels() {
  31. // NOTE The library Logger is separated from the app loggers, so the levels
  32. // have to be set in two places
  33. // Set default logging level
  34. const defaultLogLevel
  35. = loggingConfig.defaultLogLevel || JitsiMeetJS.logLevels.TRACE;
  36. Logger.setLogLevel(defaultLogLevel);
  37. JitsiMeetJS.setLogLevel(defaultLogLevel);
  38. // NOTE console was used on purpose here to go around the logging and always
  39. // print the default logging level to the console
  40. console.info(`Default logging level set to: ${defaultLogLevel}`);
  41. // Set log level for each logger
  42. if (loggingConfig) {
  43. Object.keys(loggingConfig).forEach(loggerName => {
  44. if (loggerName !== 'defaultLogLevel') {
  45. const level = loggingConfig[loggerName];
  46. Logger.setLogLevelById(level, loggerName);
  47. JitsiMeetJS.setLogLevelById(level, loggerName);
  48. }
  49. });
  50. }
  51. }
  52. /**
  53. * Initializes logging in the app.
  54. *
  55. * @private
  56. * @returns {void}
  57. */
  58. function _initLogging() {
  59. // Adjust logging level
  60. _configureLoggingLevels();
  61. // Create the LogCollector and register it as the global log transport. It
  62. // is done early to capture as much logs as possible. Captured logs will be
  63. // cached, before the JitsiMeetLogStorage gets ready (statistics module is
  64. // initialized).
  65. if (!APP.logCollector && !loggingConfig.disableLogCollector) {
  66. APP.logCollector = new Logger.LogCollector(new JitsiMeetLogStorage());
  67. Logger.addGlobalTransport(APP.logCollector);
  68. JitsiMeetJS.addGlobalLogTransport(APP.logCollector);
  69. }
  70. }