Console methods in the front end
Drupal logs in the back end
Log detail

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?

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/jslog if 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

Dependencies

Supporting organizations: 
Development

Project information

Releases