Git Product home page Git Product logo

laravel-rollbar's Introduction

Laravel Rollbar

Build Status Coverage Status

Rollbar error monitoring integration for Laravel projects. This library adds a listener to Laravel's logging component. Laravel's session information will be sent in to Rollbar, as well as some other helpful information such as 'environment', 'server', and 'session'.

rollbar

Installation

Install using composer:

composer require jenssegers/rollbar

Add the service provider to the 'providers' array in config/app.php:

Jenssegers\Rollbar\RollbarServiceProvider::class,

If you only want to enable Rollbar reporting for certain environments you can conditionally load the service provider in your AppServiceProvider:

    public function register()
    {
        if ($this->app->environment('production')) {
            $this->app->register(\Jenssegers\Rollbar\RollbarServiceProvider::class);
        }
    }

Configuration

This package supports configuration through the services configuration file located in config/services.php. All configuration variables will be directly passed to Rollbar:

'rollbar' => [
    'access_token' => env('ROLLBAR_TOKEN'),
    'level' => env('ROLLBAR_LEVEL'),
],

The level variable defines the minimum log level at which log messages are sent to Rollbar. For development you could set this either to debug to send all log messages, or to none to sent no messages at all. For production you could set this to error so that all info and debug messages are ignored.

Usage

To automatically monitor exceptions, simply use the Log facade in your error handler in app/Exceptions/Handler.php:

public function report(Exception $exception)
{
    \Log::error($exception); //rollbar
    parent::report($exception);
}

For Laravel 4 installations, this is located in app/start/global.php:

App::error(function(Exception $exception, $code)
{
    Log::error($exception);
});

Your other log messages will also be sent to Rollbar:

\Log::debug('Here is some debug information');

NOTE: Fatal exceptions will always be sent to Rollbar.

Context informaton

You can pass user information as context like this:

\Log::error('Something went wrong', [
    'person' => ['id' => 123, 'username' => 'John Doe', 'email' => '[email protected]']
]);

Or pass some extra information:

\Log::warning('Something went wrong', [
    'download_size' => 3432425235
]);

laravel-rollbar's People

Contributors

antonioribeiro avatar bkuhl avatar brianr avatar charles-rumley avatar chuprik avatar cyrrill avatar dougsisk avatar ilm126 avatar jenssegers avatar jnbn avatar lowerends avatar lucasmpb avatar omranic avatar potsky avatar sdebacker avatar throck95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-rollbar's Issues

Composer require issue

Hi,

When i run this composer require jenssegers/rollbar from terminal i got the following error:-

Failed to decode response: zlib_decode(): data error
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
Your configuration does not allow connections to http://87.98.253.214/p/illuminate/console%240363645b3378a62def27cc9de3173a3f24749ca485815412b92a7de94f80430b.json. See https://getcomposer.org/doc/06-config.md#secure-http for details.

any help,

Thanks,

Ignore some exceptions

Hello,

I have set the level configuration to error and also the $dontReport variable in app/Exceptions/Handler.php but keep getting error tracking for 404 and wrong CSRF token.

    protected $dontReport = [
        'Symfony\Component\HttpKernel\Exception\HttpException',
        'Symfony\Component\HttpKernel\Exception\NotFoundHttpException',
        'Illuminate\Session\TokenMismatchException'
    ];

Can you help me to avoid reporting those errors ?

Regards

Do not works with AWS SQS

For some reason, it don't works with the queue service of Amazon.

See the error: [2014-08-30 05:29:11] production.ERROR: exception 'ReflectionException' with message 'Class Jenssegers\Rollbar\Job does not exist' in /home/forge/encomen.de/bootstrap/compiled.php:241 (and follow a bunch of errors)

Another request is option to disable forced use of queue. I want to use queue, but if it has a problem, I can try use the default queue function...

Rollbar versioning problems.

Is using ~ in composer.json a good idea?

~ is the "next significant release" operator, however Rollbar doesn't seems to follow semver and adjust versions that have BC changes in them while using the middle x.*.x version number.

I am in the process of upgrading some packages and noticed that Rollbar got upgraded to 0.12.1 and noticed some of my messages are getting scrubbed.

~0.11 is equivalent to >=0.11 < 1.0.0. If you use ~0.11.0 then it is equivalent to >=0.11.0 < 0.12.0

Only in production environment

How can i enable the Rollbar only for production mod, i don't want to be spammed in my emaisl while my ap is locally.

Map PSR-3 levels to the ones available in Rollbar

Rollbar only tracks 5 of the 8 PSR-3 levels. This means that some log levels are not being registered with the correct severity:

  • Log::error() -> gets logged as an error
  • Log::critical() -> gets logged as critical
  • Log::emergency -> gets logged as error
  • Log::alert -> gets logged as error

Since emergency and alert is more severe than error, it should at least get mapped to critical so that its properly logged in rollbar.

Upgrade to 0.15.0

Inside the Rollbar dashboard we see a warning that our version of rollbar-php is outdated.

Detect Environment

Hello,
Is it possible to add something in the configuration file that allows to only send errors to rollbar on certain environment ? Like, I don't necessary need to log errors to rollbar when I am working in local. Only in Staging and production for example.

Before I was using a simple if (env('APP_ENV') != 'local') to trigger the rollbar report, but since Laravel 5.2 it seems that doesn't work anymore :(

Many thanks

Sending messages on level none

Hey, I'm a big fan of rollbar and I want to say how happy I am to be using the Laravel wrapper you've provided :)

One question though - I've configured the level to none but error messages are still sent to rollbar. :( Is this how it's supposed to work or is it a bug only on my end?

Thanks

PHP errors not sent to Rollbar

If there's a PHP error in your application, the error won't get sent to Rollbar as Laravel's shutdown function won't get fired. The errors are more likely to get sent if register_shutdown_function is used:

register_shutdown_function(function () {
    $rollbar = App::make('rollbar');
    $rollbar->flush();
});

Maybe add it after/instead of the $this->app->shutdown call?

Lumen Support

Hi, is there any chance you'd be able to offer this with support for Lumen 5.1?

Disabling Rollbar for local and testing environments

Since laravel-rollbar throws an Exception if no access token is set, I'm not sure about the way to disable it for local testing.

Is there a suggested way to configure no ACCESS_TOKEN for testing/continuous integration environments?

I'm currently adding this to register() at AppServiceProvider.php

if ($this->app->environment() != 'testing') {
    $this->app->register(Jenssegers\Rollbar\RollbarServiceProvider::class);
}

But unsure about if it's the best way.

Thanks in advance!

Duplicate

Your usage documentation suggests using Log facade to log all exceptions for Rollbar. ie)

public function report(Exception $e)
{
    \Log::error($e);
    return parent::report($e);
}

However, the parent::report($e) call there also logs exceptions. This means that reportable exceptions are being logged twice. Can we not just let the parent::report($e) method do the logging? Thoughts?

Updating Rollbar Dependency

Rollbar has relased v.1.0.1 , this package currently is using version 0.15 , will updating to 1.0 break anything? otherwise it might be good to update the dependency.

JSON Body not sent to rollbar

Is it just me or is the json body of a request not sent along with the error?
I get headers & GET/POST data, but no JSON body content

Uncaught exception 'Mockery\Exception\NoMatchingExpectationException'

I get this error when I run my tests:

PHP Fatal error: Uncaught exception 'Mockery\Exception\NoMatchingExpectationException' with message 'No matching handler found for Mockery_0_Illuminate_Config_Repository::get('services.rollbar'). Either the method was unexpected or its arguments matched no expected argument list for this method

Any help guys

Broken on Laravel 4.2

PHP Fatal error:  Class 'RollbarNotifier' not found in /home/notify/builds/jenkins-dialnotify-production-35/vendor/jenssegers/rollbar/src/RollbarServiceProvider.php on line 51

Noticied that after composer update.

Rollbar not working from AWS

Hi,

I have issue only with my servers on AWS (EC2).
When I want to log something from whatever environment (local, stage, production) on my local computer or on one shared hosting, it works.

But on AWS I have stage and production servers and none of them is passing the logs to Rollbar.
I was on the email with Rollbar support and we did some pings, and it all looks ok. Can't find the source of the problem so if someone had the same issue it would be very helpful.

This stands for both, error handler in Laravel and just any other Log::error call in the app.

Here is services.php part:

'rollbar' => [
    'access_token'   => 'TAKEN FROM ROLLBAR ACCOUNT',
    'level'   => env('APP_ENV') == 'production' ? 'error' : 'debug',
],

Any ideas?

checkIgnore config option

We're using rollbar to publish exceptions from client installations (out of our control). Sometimes we're noticing thousands of exceptions being published and as far as I'm aware we can't stop them from rollbar's end.

I've tried rate limiting but this is pretty useless as it just results in one user filling the quota and all valid notifications there after being ignored.

The following seems like it's rollbar's solution for filtering requests before they get published to the API:
https://rollbar.com/docs/filter-or-ignore-errors-from-bots/

Would it be possible to add support for this?

You could probably just add the following to the config file and update the provider:

'checkIgnore' => function ($isUncaught, $args, $payload) {
     return true;
}

artisan clear-compiled fails if the access token is not configured

My deployment script packages the build in a separate directory where the .env file is not present (and thus the access token is empty). When php artisan clear-compiled is ran, the build halts with the following error:

  [RuntimeException]                                                                                                                                                                                                                                                   
  Error Output: PHP Fatal error:  Uncaught exception 'InvalidArgumentException' with message 'Rollbar access token not configured' in [..]/vendor/jenssegers/rollbar/src/RollbarServiceProvider.php:51  
  Stack trace:                

For the sake of context, I have my services.php configured as follows:

    'rollbar' => [
        'access_token' => env('ROLLBAR_ACCESS_TOKEN'),
        'level'        => env('ROLLBAR_LEVEL')
    ],

I think a solution would be to make the access_token an optional configuration parameter, in such a way that the rollbar log handler simply does not register if it is not set. Am I welcome to submit a PR?

#1 API error: Cannot read property 'trace' of undefined

I'm unsure if this is an issue with this package or something within Rollbar. I just added this to my Laravel 5 project and am testing things out and Rollbar is seeing an exception, but it's not the one I'm throwing. I'm unfamiliar with Rollbar so I'm having trouble determining what the cause of this exception is.

To get this, I set things up and simply threw an exception in my controller.

screen shot 2016-06-11 at 1 59 08 pm

screen shot 2016-06-11 at 2 01 52 pm

Any ideas on where this is coming from?

Integration with Auth::user()

I'm interested in integrating this with Auth::user() to get the user email, id, etc.

Is there a reason this isn't included by default, either in the code or the documentation?

Access token... which one?

I cannot find in the documentation which access token I use.
server-side or client-side?

I am not receiving anything in my dashboard yet. I haveit working on other projects, but every time I come up against this. The lack of documentatio0jn explaining the difference and which one to use. Also looking in the Project Access Tokens I see 4 tokens.

in the services.php file you can only put one..... which one??

Turn off for certain environments.

How can I disable the provider on an environment basis?

For example, previously I set rollbar => null in the services.php config file and it wouldn't try registering it.

Now it throws the error of "access token not configured".

Is there another way to conditionally disable the provider based on environment?

Flush error in Laravel 4

Call to undefined method Illuminate\Foundation\Application::resolved() in /var/www/booking/vendor/jenssegers/rollbar/src/RollbarServiceProvider.php on line 34

I've not tried Laravel 5 so not sure what the best fix is, but changing the code from this:

    // Flush callback
    $flush = function() use ($app)
    {
        if ($app->resolved('rollbar.client'))
        {
            $app['rollbar.client']->flush();
        }
    };

To this:

    // Flush callback
    $flush = function() use ($app)
    {
        if ($app->app['rollbar.client'])
        {
            $app['rollbar.client']->flush();
        }
    };

Worked for me

Cannot install via composer - UnexpectedValueException

Attempting to install via composer throws the following error

$ composer require jenssegers/rollbar
Please provide a version constraint for the jenssegers/rollbar requirement

And with dev-master as the version:

$ composer require jenssegers/rollbar:dev-master
./composer.json has been updated


 [UnexpectedValueException]
 Could not parse version constraint ^1.0.2: Invalid version string "^1.0.2"


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update]
[packages1] ... [packagesN]

Turn off on development

Hi,

first thanks for this package, good work ๐Ÿ‘

Could you tell me how i can disable this package / notifications on my local development?

Rollbar access token required

Of course, for this to work, there must be a valid Rollbar access_token.

However, the RollbarServiceProvider::register() function checks for the access_token and quickly returns if it is not found. The RollbarServiceProvider::boot() method does not check to see if the RollbarLogHandler was registered before trying to access it.

Override environment

Great working package, also with Laravel 5, thanks!

Is there a way to override the environment variable that is sent to Rollbar? Currently this is set in the constructor to Laravel's app environment, but I was wondering if this could be overridden from the configuration settings. It would be something like this:

'rollbar' => array(
    'access_token' => 'access-token',
    'level' => 'debug',
    'environment' => 'custom-environment-string',
),

If it's not possible yet and you're open for it, then I'd be happy to create a pull request for this somewhere in the coming weeks.

FR: minimum log level & user data

Is there a way to limit the amount of logging that gets sent to rollbar by setting the minimum in the config? For example, only send anything Log::warning + above and skip Log::debug/info or limit by environment.

Also because services.php is an array, is there another way to attach user data?

I love to use this library for it's queuing integration, however too much information gets sent to Rollbar and some of the information becomes missing.

InvalidArgumentException not working

When access_token is not set, than InvalidArgumentException returns nothing instead of "Rollbar token is not set" and then no exeptions are returned.

Would be nice if you could configure, when you can enable or disable rollbar in your project. Maybe if you not set access_token, than exeptions will return normal laravel exceptions and if it's set than rollbar execptions.

Rollbar not being instantiated on command-line

When using php artisan migrate and there is an error (I just attempted to migrate with TestDummy without having it installed), we first receive the fatal error PHP Fatal error: Class 'Laracasts\TestDummy\Factory' not found in, then a stack trace, then our symphony FatalErrorException
screen shot 2015-05-28 at 17 22 49

And then we get, instead of reporting the error to Rollbar, PHP Fatal error: Call to a member function report_php_error() on null in /directory/to/repository/vendor/rollbar/rollbar/src/rollbar.php on line 61.

So how can we pull in Rollbar even for artisan commands? (since the App is never loaded)

Cannot get this to function in Laravel 5.0.17

Hi,

For whatever reason, I just cannot get this to send any information to Rollbar in either production or local environments. No errors are shown with regards to installation. I can log errors just fine to my Laravel log file however I just cannot seem to send any data over to Rollbar.

Has this been tested with 5.0.17?

rollbar-php 0.18, checkIgnore fatal error

When I try to use the new checkIgnore functionality for rollbar-php (https://rollbar.com/docs/notifier/rollbar-php/#configuration-reference), I get a fatal error:

Fatal error: Uncaught ReflectionException: Class log does not exist in /Users/mark/Sites/[...]/vendor/laravel/framework/src/Illuminate/Container/Container.php:734

Stack trace: 
#0 /Users/mark/Sites/[...]/vendor/laravel/framework/src/Illuminate/Container/Container.php(734): ReflectionClass->__construct('log') 
#1 /Users/mark/Sites/[...]/vendor/laravel/framework/src/Illuminate/Container/Container.php(629): Illuminate\Container\Container->build('log', Array) 
#2 /Users/mark/Sites/[...]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(697): Illuminate\Container\Container->make('log', Array) 
#3 /Users/mark/Sites/[...]/vendor/graham-campbell/exceptions/src/ExceptionHandler.php(49): Illuminate\Foundation\Application->make('log') 
#4 [internal function]: GrahamCampbell\Exceptions\ExceptionHandler->__construct(Object(Illuminate\Foundation\Application)) 
#5 /Users/mark/Sites/[...]/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass- in /Users/mark/Sites/[...]/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 734

Not working: Rollbar::report_exception($e)

Hi. In previous projects, I liked to use the following syntax for reporting an Exception to Rollbar.

Rollbar::report_exception($e);

This outputs a lot of meta information (like stacktraces), which can be very useful.

However, this doesn't seem to work well with this package: My Exceptions aren't reported to rollbar.

Any idea how I can fix this?

How can I set code_version in Laravel 5?

I'm using Git and I've a config file called version.php, so if I do Config::get('version.version') I get the version code from git. My question is how can I set this value into code_version before sending error?
(I'm using Laravel 5)

A link to rollbar.com?

The README,md does not once link to the underlying service, rollbar.com

Just for convenience, it may be worth mentioning for the unitiated, right at the top, what this is all about, with a link to the thing that this is really all about.

New release?

It's been 6 months since the 1.4.4 release but there are few improvements on the code so can you please release to make it possible for everyone access the latest version from composer too?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.