Files
playwriter/extension-kapture/modules/background-console.js
Tommy D. Rossi ec02a90812 adding examples
2025-11-13 19:42:44 +01:00

22 lines
764 B
JavaScript

// Import helper functions from background-commands
import { respondWith, respondWithError } from './background-commands.js';
export async function getLogs(tabState, { before, limit = 100, level }) {
try {
// Get the logs from the tab state using its built-in method
const logs = tabState.getConsoleLogs(limit, level, before);
// Check if there are more logs available
const totalFilteredCount = tabState.getConsoleLogs(null, level, before).length;
const hasMore = totalFilteredCount > limit;
return respondWith(tabState.tabId, {
logs: logs,
hasMore: hasMore,
totalCount: tabState.getConsoleLogCount()
});
} catch (error) {
return respondWithError(tabState.tabId, 'CONSOLE_LOG_ERROR', error.message);
}
}