Comments (6)
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.
like a console.read(100);
where 100 is the max number of lines to return?
from console.
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.
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.
would console.read() also include the script source? i.e. "some message" app.js:45
from console.
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)
- window.onconsoleopen Event HOT 4
- Remove NOTES.md
- How to tabulate an object shown by console.dir? HOT 1
- Pushing on a group stack not defined HOT 2
- console.context() HOT 2
- console.memory
- Add integration hooks for WebDriver-BiDi HOT 3
- Handling of ANSI escape codes HOT 4
- Feature request: being able to update a already logged value HOT 5
- Feature request: Ability to switch on and off particular log type -> console.(INFO,WARN,ERROR,TRACE etc) HOT 1
- Define which methods should provide a stacktrace HOT 6
- Formatter algorithm does not handle having no format specifiers HOT 3
- feature request: add `console.color` HOT 2
- add `console.log` function to window, so we can use `log` direct! HOT 5
- console.json HOT 11
- What should `console.assert(false, { a: 1 })` print? HOT 8
- Deprecate groupCollapsed in favor of group and groupEnd
- Minor wording change in assert() definition HOT 7
- Changes in Logger() definition HOT 3
- Change in organization of the definition of Formatter() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from console.