Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

JitsiMeetLogStorage.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* global APP */
  2. /**
  3. * Implements logs storage through the CallStats.
  4. */
  5. export default class JitsiMeetLogStorage {
  6. /**
  7. * Creates new <tt>JitsiMeetLogStorage</tt>
  8. */
  9. constructor() {
  10. /**
  11. * Counts each log entry, increases on every batch log entry stored.
  12. * @type {number}
  13. */
  14. this.counter = 1;
  15. }
  16. /**
  17. * Called by the <tt>LogCollector</tt> to store a series of log lines into
  18. * batch.
  19. * @param {string|object[]}logEntries an array containing strings
  20. * representing log lines or aggregated lines objects.
  21. */
  22. storeLogs(logEntries) {
  23. let logJSON = '{"log' + this.counter + '":"\n';
  24. for (let i = 0, len = logEntries.length; i < len; i++) {
  25. let logEntry = logEntries[i];
  26. if (typeof logEntry === 'object') {
  27. // Aggregated message
  28. logJSON += '(' + logEntry.count + ') ' + logEntry.text + '\n';
  29. } else {
  30. // Regular message
  31. logJSON += logEntry + '\n';
  32. }
  33. }
  34. logJSON += '"}';
  35. this.counter += 1;
  36. // Try catch was used, because there are many variables
  37. // on the way that could be uninitialized if the storeLogs
  38. // attempt would be made very early (which is unlikely)
  39. try {
  40. // Currently it makes sense to store the log only
  41. // if CallStats is enabled
  42. if (APP.logCollectorStarted
  43. && APP.conference
  44. && APP.conference.isCallstatsEnabled()) {
  45. APP.conference.logJSON(logJSON);
  46. }
  47. } catch (error) {
  48. // NOTE console is intentional here
  49. console.error(
  50. "Failed to store the logs: ", logJSON, error);
  51. }
  52. }
  53. }