DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:sentry

sentry Plugin

Compatible with DokuWiki

  • 2018-04-22 "Greebo" yes
  • 2017-02-19 "Frusterick Manners" unknown
  • 2016-06-26 "Elenor Of Tsort" unknown
  • 2015-08-10 "Detritus" unknown

plugin Log errors to Sentry

Last updated on
2018-06-12
Provides
Helper, Action
Repository
Source

Tagged with devel, logging

A CosmoCode Plugin

This plugin will log errors and exceptions in DokuWiki's PHP backend and the JavaScript frontend to a Sentry instance. You can either use sentry.io or a self hosted instance.

Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Privacy Info: when you install this plugin in a live wiki, you probably need to inform your users that their personal information (username, email, IP-Address, browser info) is logged to Sentry in case of an unforeseen error. Sentry also offers some detailed setting to configure how long personal data is retained.

Changes

Configuration

Use the extension manager and configure the DSN to you sentry project. You can find it under ProjectSettingsClient Keys.

It should look like this: https://<public>:<secret>@<sentryinstance>/<projectid>.

You can configure which kind of errors should be logged via the errors configuration setting. It defaults to what is set for PHP's error_reporting and accepts the same integer. You can use this calculator to figure out the value you want.

The env variable allows you to easily differentiate between multiple wikis being logged into the same Sentry. This is useful when you have a local development and a live wiki for example.

Usage

Once installed and configured, it will log all unhandled errors to Sentry automatically.

You can also use it in your code for specialized logging.

PHP

To log an error use the helper plugin:

try {
    // some code
} catch(\Exception $e) {
    $sentry = plugin_load('helper', 'sentry');
    if($sentry) $sentry->logException($e);
    msg(hsc($e->getMessage()), -1);
}

The helper plugin exposes some more public methods in case you need more control.

You can also use the following to log an arbitrary message and additional data. (Useful when debugging problems on a live server):

$sentry = plugin_load('helper','sentry');
if($sentry) {
     $sentry->logMessage('my log message', array( 'something' => $info) );
}

JavaScript

To log an error, call the SentryPlugin.logSentryException() method.

try {
    // some code
} catch(error) {
    window.SentryPlugin && SentryPlugin.logSentryException(error, {});
    console.log(error)
}
plugin/sentry.txt · Last modified: 2018-06-12 23:52 by andi