Technologies:
Tolerim
21 hours ago
What is the method for capturing console warnings and verbose messages?
// Set the current tab ID as tabId and attach the debugger to it
chrome.debugger.attach({ tabId }, '1.3', onDebuggerAttach.bind(null, tabId));
// Enable Log and Runtime domains
const onDebuggerAttach = async tabId => {
await chrome.debugger.sendCommand({ tabId: tabId}, 'Log.enable');
await chrome.debugger.sendCommand({ tabId: tabId}, 'Runtime.enable');
chrome.debugger.onEvent.addListener(onDebugEvent);
};
// Retrieve console messages
const onDebugEvent = (debuggeeId = {}, message, params = {}) => {
switch (message) {
case 'Log.entryAdded':
case 'Runtime.consoleAPICalled':
handleConsoleMessage(params);
break;
default:
break;
}
};
Answers(1)
Tolerim
21 hours ago
Verified Answer
It seems like you are attaching the Debugger Protocol to the tab and enabling the Log and Runtime domains correctly. However, the reason you may not be getting all the verbose messages is that you might not have set the correct verbosity level for the Log.enable command.
You can try passing an Object parameter with a level property to the Log.enable command, where the level value is 'verbose'. Here's an example:
await chrome.debugger.sendCommand({ tabId }, 'Log.enable', { level: 'verbose' });
This should give you more detailed log messages. Additionally, keep in mind that not all console messages may be captured depending on the context of the page you are debugging.