This project is not covered by Drupal’s security advisory policy.
Log all javascript messages to the Drupal log.
What messages or events are logged?
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.
How does it work?
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!
Installation
- Enable the module
- Choose whose messages are logged via
admin/people/permissions/module/jslog - Fine-tune configuration via
/admin/config/system/jslogif needed
DoS protection
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.
Extending functionality in the frontend
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: {message, type}}) => {
// message: the log message
// type: debug, info, notice, warning, or error
}, {passive: false})
Using the original console methods
If you want to use the original methods, just use console.original:
console.original.log('Well done!')
Browser support
- Browsers that support optional chaining.
Dependencies
- Composer package
donatj/phpuseragentparserto log metadata like browser & OS.
Project information
- Project categories: Developer tools
3 sites report using this module
- Created by martijn.cuppens on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.


