Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: console level #744

Closed
furstenheim opened this issue Sep 11, 2017 · 2 comments
Closed

Feature request: console level #744

furstenheim opened this issue Sep 11, 2017 · 2 comments
Labels

Comments

@furstenheim
Copy link

Page offers a console event but it is not possible to know the level of the message (log, error...).

page.on('console', function (...args) {
    // No way to know if this is an error
})

Would it be possible to implement a way to know the level? I don't know what would be the cleanest way, either one more event per level:

page.on('consoleError', ...)

or a new type of event:

page.on('consoleWithType', function ({type, args}) ...

Basically here: https://github.com/GoogleChrome/puppeteer/blob/master/lib/Page.js#L308 the event type is totally ignored

@ebidel ebidel added the feature label Sep 11, 2017
michaelfward added a commit to michaelfward/puppeteer that referenced this issue Sep 18, 2017
michaelfward added a commit to michaelfward/puppeteer that referenced this issue Sep 18, 2017
@michaelfward
Copy link

michaelfward commented Sep 18, 2017

@ebidel - I didn't know if creating a Console object with its own Events class property would be preferable; I couldn't find anywhere else in the project that didn't explicitly declare it's events, or emit more than one at a time.

Let me know what you recommend and I'll submit a PR!

@aslushnikov
Copy link
Contributor

@michaelfward I like page.console namespace that will deliver specific events; go for it!

page.console.on('log', console.log);
page.console.on('warn', console.warn);
page.console.on('debug', console.debug);
page.console.on('pageerror', console.error);

aslushnikov added a commit that referenced this issue Sep 29, 2017
This patch introduces ConsoleMessage type and starts dispatching
it for the 'console' event.

BREAKING CHANGE: this breaks the api of the 'console' event.

Fixes #744.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants