Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

functions.web.js 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. // Force enable the API if jwt token is passed because most probably
  22. // jitsi meet is displayed inside of wrapper that will need to communicate
  23. // with jitsi meet.
  24. APP.API.init(APP.tokenData.jwt ? { forceEnable: true } : undefined);
  25. APP.translation.init(settings.getLanguage());
  26. }
  27. /**
  28. * Adjusts the logging levels.
  29. *
  30. * @private
  31. * @returns {void}
  32. */
  33. function _configureLoggingLevels() {
  34. // NOTE The library Logger is separated from the app loggers, so the levels
  35. // have to be set in two places
  36. // Set default logging level
  37. const defaultLogLevel
  38. = loggingConfig.defaultLogLevel || JitsiMeetJS.logLevels.TRACE;
  39. Logger.setLogLevel(defaultLogLevel);
  40. JitsiMeetJS.setLogLevel(defaultLogLevel);
  41. // NOTE console was used on purpose here to go around the logging and always
  42. // print the default logging level to the console
  43. console.info(`Default logging level set to: ${defaultLogLevel}`);
  44. // Set log level for each logger
  45. if (loggingConfig) {
  46. Object.keys(loggingConfig).forEach(loggerName => {
  47. if (loggerName !== 'defaultLogLevel') {
  48. const level = loggingConfig[loggerName];
  49. Logger.setLogLevelById(level, loggerName);
  50. JitsiMeetJS.setLogLevelById(level, loggerName);
  51. }
  52. });
  53. }
  54. }
  55. /**
  56. * Initializes logging in the app.
  57. *
  58. * @private
  59. * @returns {void}
  60. */
  61. function _initLogging() {
  62. // Adjust logging level
  63. _configureLoggingLevels();
  64. // Create the LogCollector and register it as the global log transport. It
  65. // is done early to capture as much logs as possible. Captured logs will be
  66. // cached, before the JitsiMeetLogStorage gets ready (statistics module is
  67. // initialized).
  68. if (!APP.logCollector && !loggingConfig.disableLogCollector) {
  69. APP.logCollector = new Logger.LogCollector(new JitsiMeetLogStorage());
  70. Logger.addGlobalTransport(APP.logCollector);
  71. JitsiMeetJS.addGlobalLogTransport(APP.logCollector);
  72. }
  73. }