2018-04-24 18:56:54 +00:00
|
|
|
/**
|
|
|
|
* Implements in memory logs storage, used for testing/debugging.
|
2018-09-05 20:23:57 +00:00
|
|
|
*
|
2018-04-24 18:56:54 +00:00
|
|
|
*/
|
|
|
|
export default class JitsiMeetInMemoryLogStorage {
|
2022-08-04 08:51:33 +00:00
|
|
|
logs: string[] = [];
|
2018-04-24 18:56:54 +00:00
|
|
|
|
|
|
|
/**
|
2018-09-05 20:34:26 +00:00
|
|
|
* Creates new <tt>JitsiMeetInMemoryLogStorage</tt>.
|
2018-04-24 18:56:54 +00:00
|
|
|
*/
|
|
|
|
constructor() {
|
|
|
|
/**
|
|
|
|
* Array of the log entries to keep.
|
2021-11-04 21:10:43 +00:00
|
|
|
*
|
2018-04-24 18:56:54 +00:00
|
|
|
* @type {array}
|
|
|
|
*/
|
|
|
|
this.logs = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-09-05 20:34:26 +00:00
|
|
|
* Checks if this storage instance is ready.
|
|
|
|
*
|
2018-04-24 18:56:54 +00:00
|
|
|
* @returns {boolean} <tt>true</tt> when this storage is ready or
|
|
|
|
* <tt>false</tt> otherwise.
|
|
|
|
*/
|
|
|
|
isReady() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by the <tt>LogCollector</tt> to store a series of log lines into
|
|
|
|
* batch.
|
2018-09-05 20:34:26 +00:00
|
|
|
*
|
|
|
|
* @param {string|Object[]} logEntries - An array containing strings
|
2018-04-24 18:56:54 +00:00
|
|
|
* representing log lines or aggregated lines objects.
|
2018-09-05 20:34:26 +00:00
|
|
|
* @returns {void}
|
2018-04-24 18:56:54 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
storeLogs(logEntries: (string | { text: string; })[]) {
|
2018-04-24 18:56:54 +00:00
|
|
|
for (let i = 0, len = logEntries.length; i < len; i++) {
|
|
|
|
const logEntry = logEntries[i];
|
|
|
|
|
|
|
|
if (typeof logEntry === 'object') {
|
|
|
|
this.logs.push(logEntry.text);
|
|
|
|
} else {
|
|
|
|
// Regular message
|
|
|
|
this.logs.push(logEntry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-09-05 20:34:26 +00:00
|
|
|
* Returns the logs stored in the memory.
|
|
|
|
*
|
|
|
|
* @returns {Array<string>} The collected log entries.
|
2018-04-24 18:56:54 +00:00
|
|
|
*/
|
|
|
|
getLogs() {
|
|
|
|
return this.logs;
|
|
|
|
}
|
|
|
|
}
|