jotafurtado / getsentry by jotafurtado

Sentry Integration for Laravel 4
2,264
3
1
Package Data
Maintainer Username: jotafurtado
Maintainer Contact: jotacfurtado@gmail.com (João Carlos)
Package Create Date: 2014-07-21
Package Last Update: 2016-10-25
Language: PHP
License: MIT
Last Refreshed: 2024-11-22 03:12:55
Package Statistics
Total Downloads: 2,264
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 3
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Sentry Integration for Laravel 4

Sentry (getsentry.com) and Laravel 4 integration. Automatically send Laravel log messages to Sentry. This package integrates Sentry and Laravel 4 in a super simple way. Let's see how it works.

Installation

The package can be installed via Composer by requiring the jcf/getsentry package in your project's composer.json.

{
    "require": {
        "jcf/getsentry": "1.1.*"
    }
}

Then run a composer update

php composer.phar update

After updating composer, add the ServiceProvider to the providers array in app/config/app.php

'Jcf\Getsentry\GetsentryServiceProvider',

Configuration

Run php artisan config:publish jcf/getsentry to publish the configuration file.

php artisan config:publish jcf/getsentry

Edit the configuration file at /app/config/packages/jcf/getsentry. You may also create environment specific configuration files for your package by placing them in app/config/packages/jcf/getsentry/dev by example.

Options

Provide Sentry DSN of your project. You can grab this at Settings Tab / API Keys of your project on getsentry.com.

return array(

    'dsn' => 'https://1f68584cfb824d123432534ab452adb778:7e06629189c02355bd2b928881a4c1f1@app.getsentry.com/26241',

Then set the environments that should be reported to Sentry.

    'environments' => ['stagging', 'production'],

Set the log levels that should be reported to Sentry.

    'environments' => ['error', 'emergency', 'notice', 'info', 'debug'],

Set if Sentry Event ID should be saved in session. This is useful if you want to share the event ID with your users.

    'saveEventId' => true,

Usage

Automatically every message that will be logged by Laravel and that fits in rules of configuration will be sent to Sentry.

If you need, you may also trigger Laravel log mannualy and pass extra data to Sentry.

	// Debug with User and Extra Data
    \Log::debug('Debugging', [
	'user' => [
		'id' => 99,
		'email' => 'joao@3eengenharia.com.br',
		'data' =>[
			'Member Since' => '2011-09-07'
		]
	]
	, 'extra' => ['Ammount' => '142', 'Membership' => 'Activated']]
    );

    // Debug with User
    \Log::debug('Debug bug!', ['user' => 'jotafurtado']);

    // Info with User
    \Log::info('User has logged in.', ['user' => 'jotafurtado']);

    // Simple Error
    \Log::error('Image not saved.');

To retrieve event ID use the code:

 \Session::get('sentryEventId');