Skip to content

jotafurtado/getsentry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:[email protected]/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' => '[email protected]',
		'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');

About

Super Simple Sentry Integration for Laravel 4

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages