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.4KB

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