I need to make an HTML pseudo console (a normal div to append console logs, info, warnings and errors). All solutions I've seen so far only work with events which I directly initiate. But not when the browser itself logs an error (like from a 404 fetch event). Is there any way I can intercept the browser-initiated console events as well?
Asked
Active
Viewed 494 times
0
-
Did the answers to the question “[Intercept calls to console.log](https://stackoverflow.com/questions/9216441/intercept-calls-to-console-log-in-chrome)” not help? – David Thomas Jun 06 '19 at 21:19
1 Answers
0
You can use the GlobalEventHandlers.onerror
https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror

Andoni
- 171
- 9
-
Other than the fact this doesn’t catch user-logging (`console.log()`) as specified in the question, how should OP use this? The link may contain details, but the link will, over time, also maybe die, rot, be moved, refer to obsoleted or deprecated APIs or otherwise become useless. Include an explanation of how the `GlobalEventHandlers.onerror` may be used to address and answer the OP’s problem. Link-only answers are, for the reasons above, not usually considered valid. – David Thomas Jun 06 '19 at 21:29