Special: log page
Log all javascript messages to the Drupal log.
console.debug()messages are logged as debug messages.console.info()messages are logged as info messages.console.log()messages are logged as info messages.console.warn()messages are logged as warnings.console.error()messages are logged as errors.unhandledrejection eventsare logged as notices.error eventsare logged as errors.
The native console.debug(), console.info(), console.warn(), and console.error() methods are extended with a fetch to the Drupal server, logging appropriate messages. The events are handled with eventListeners in a similar way.
This means there's no need to add any custom javascript code to make this module work!
- Enable the module
- Choose whose messages are logged via
admin/people/permissions/module/jslog - Fine-tune configuration via
/admin/config/system/jslogif needed
Javascript loops can cause a DoS attack on the server. Therefor requests to the server are queued in Promises. Also, there is a configurable limit to the number of messages that can be logged per page.
Whenever a message is logged, the custom jslog event is dispatched. This event can be used to show messages to the frontend if suitable:
addEventListener('jslog', ({detail: {value, level}}) => {
// value: the log message
// level: debug, info, notice, warning, or error
}, {passive: false})- Browsers that support optional chaining.
None