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.

JitsiMeetInMemoryLogStorage.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Implements in memory logs storage, used for testing/debugging.
  3. *
  4. */
  5. export default class JitsiMeetInMemoryLogStorage {
  6. /**
  7. * Creates new <tt>JitsiMeetInMemoryLogStorage</tt>.
  8. */
  9. constructor() {
  10. /**
  11. * Array of the log entries to keep.
  12. * @type {array}
  13. */
  14. this.logs = [];
  15. }
  16. /**
  17. * Checks if this storage instance is ready.
  18. *
  19. * @returns {boolean} <tt>true</tt> when this storage is ready or
  20. * <tt>false</tt> otherwise.
  21. */
  22. isReady() {
  23. return true;
  24. }
  25. /**
  26. * Called by the <tt>LogCollector</tt> to store a series of log lines into
  27. * batch.
  28. *
  29. * @param {string|Object[]} logEntries - An array containing strings
  30. * representing log lines or aggregated lines objects.
  31. * @returns {void}
  32. */
  33. storeLogs(logEntries) {
  34. for (let i = 0, len = logEntries.length; i < len; i++) {
  35. const logEntry = logEntries[i];
  36. if (typeof logEntry === 'object') {
  37. this.logs.push(logEntry.text);
  38. } else {
  39. // Regular message
  40. this.logs.push(logEntry);
  41. }
  42. }
  43. }
  44. /**
  45. * Returns the logs stored in the memory.
  46. *
  47. * @returns {Array<string>} The collected log entries.
  48. */
  49. getLogs() {
  50. return this.logs;
  51. }
  52. }