Code Monkey home page Code Monkey logo

Comments (6)

domfarolino avatar domfarolino commented on May 20, 2024 1

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?

from console.

zspitzer avatar zspitzer commented on May 20, 2024

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

from console.

valtido avatar valtido commented on May 20, 2024

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

from console.

terinjokes avatar terinjokes commented on May 20, 2024

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.

from console.

zspitzer avatar zspitzer commented on May 20, 2024

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

from console.

domfarolino avatar domfarolino commented on May 20, 2024

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.

from console.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.