JSNLog Output

Overview

This module implements the JSNLog library. And stores JavaScript messages in watchdog.

Installation

  • Prefered option: composer require drupal/jsnlog.
    • For the JSNLog javascript library add:
      {
        "type": "composer",
        "url": "https://asset-packagist.org"
      }
    • extend your libraries path under installer-path:
      "web/libraries/{$name}": [
        "type:drupal-library",
        "type:bower-asset",
        "type:npm-asset"
      ],
    • add installer-types under extra:
      "installer-types": ["bower-asset", "npm-asset"],
    • and finally:
      composer require bower-asset/jsnlog
  • Manually: Place the module in the modules folder.
    • Download JSNLog library from JSNLog and place the folder under webroot/libraries named jsnlog.
    • (Optional - for better output) Download WhichBrowser library from github and place the folder under webroot/libraries named whichbrowser.
  • Activate and visit settings page.

Options

  • Enable or disable it.
  • Choose logging type: if ajax, console or both.
  • Choose library type.
  • Debug level to save into watchdog.
  • User agent filter to log only specific browsers.
  • Include or exclude roles and or pages.

Usage

If a JavaScript error occurs. The event will trigger an ajax callback and the error will be listed in watchdog.

Troubleshoot

Be beware of your adblocker. This may block the JSNLog script if
aggregation is off, or you use the CDN option.

Custom error triggers

For your custom JavaScript you may want to use some other notifications from the JSNLog library.

JL().warn("warn message");
JL().info("info message");
JL().fatal("fatal message");

Depending on your debug level you configured. These messages will be tracked as well.

Project information

Releases