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

Console log output and events feature request #53

Open
valtido opened this issue Apr 13, 2016 · 6 comments
Open

Console log output and events feature request #53

valtido opened this issue Apr 13, 2016 · 6 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@valtido
Copy link

valtido commented Apr 13, 2016

Hi,

I would like to request for a couple features, on request we should have a method that can output everything console has recorded so far like a stack list.

This is useful when you need to save it programmatically rather than debugging manually.

I would also like an event listener, so we can assign a handler and do something when there is a new entry on log, warn, error etc. Again for the same reason.

@domenic domenic added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Apr 13, 2016
@zspitzer
Copy link

like a console.read(100); where 100 is the max number of lines to return?

@valtido
Copy link
Author

valtido commented Apr 20, 2017

Yeah sure, but this doesn't work at the moment, and also could be console.on("all,error,log,warning...", callback)

Or promise instead of callback. :)

Cheers

@domfarolino
Copy link
Member

domfarolino commented Jun 7, 2017

Seems like a good idea. Some points:

1.) I think we definitely wouldn't want a promise for this sort of thing. Sounds like you'd like to extend addEventListener to console? Like console.addEventListener('warn', e => {...}) kind of? I think that could be useful. Promises don't really fit this sort of behavior IMO.

2.) IIRC as @terinjokes pointed out to me the other day in person, callbacks should only be triggered for events originating from scripts whose errors are not muted for security.

Edit:

And furthermore, if 2.) is valid, something like console.read(...) (or whatever it might be named) should only store and return messages logged from scripts whose errors are not muted as well. With that being said, if we do go on with the implementation of this, maybe it might be worth looking into renaming muted errors in the HTML spec to muted output or something that covers more bases, since we might extend it to functionality in this spec?

@terinjokes
Copy link
Collaborator

We've defined an interface in this specification. I think there's more benefit to being able to pass an implementation of that interface (which might be this Console, or something created at runtime) to the library, rather than adding and requiring eventing supporting to all console implementations.

@zspitzer
Copy link

would console.read() also include the script source? i.e. "some message" app.js:45

@domfarolino
Copy link
Member

I agree with @terinjokes on this, and I think there's more benefit to being able to build a mechanism that can do some sort of tracking when console methods are called as opposed to build that in here. This is mostly because it is only application code that calls the console methods, so application code authors (devs) should be able to easily track when these methods are being called.

It may be useful however, to be alerted when warnings are reported to the console (see #57), I guess it'd be worth polling implementers there, but I'm not sure.

Regarding console.read, there might be benefit to storing and having access to previous console output, but I think I'd need a more compelling use-case than web-platform-tests/wpt#8654 (testing). As discussed a bit in #75, there is some use but most of it isn't terribly productive so for now I'm kind of against it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

5 participants