Skip to content

Commit

Permalink
[Reporting] Add location.url info to console message logs (#101427)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan authored Jun 4, 2021
1 parent e5944a3 commit f7b5f00
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,14 @@ export class HeadlessChromiumDriverFactory {
getBrowserLogger(page: puppeteer.Page, logger: LevelLogger): Rx.Observable<void> {
const consoleMessages$ = Rx.fromEvent<puppeteer.ConsoleMessage>(page, 'console').pipe(
map((line) => {
const formatLine = () => `{ text: "${line.text()?.trim()}", url: ${line.location()?.url} }`;

if (line.type() === 'error') {
logger.error(line.text(), ['headless-browser-console']);
logger.error(`Error in browser console: ${formatLine()}`, ['headless-browser-console']);
} else {
logger.debug(line.text(), [`headless-browser-console:${line.type()}`]);
logger.debug(`Message in browser console: ${formatLine()}`, [
`headless-browser-console:${line.type()}`,
]);
}
})
);
Expand Down

0 comments on commit f7b5f00

Please sign in to comment.