Giter VIP home page Giter VIP logo

raven's Introduction

Raven

Raven is a client for recording and transmitting messages to Sentry.

Its special sauce is that it can transmit those messages to Sentry in the background. No more slow down while a HTTP request is made!

Installation

Add rcrowe\raven as a requirement to composer.json:

{
    "require": {
        "rcrowe/raven": "dev-master"
    }
}

Update your packages with composer update or install with composer install.

Usage

This library exposes the same API for recording your messages as the official raven-php client. It should just be a case of replacing Raven_Client with rcrowe\Raven\Client. For usage of recording messages checkout out raven-php.

To record a message and transmit it to Sentry straight away (the default):

$raven = new \rcrowe\Raven\Client(##DSN##);

$raven->captureMessage('FooBar');

Handlers

Handlers are responsible for taking a new captured raven message and putting into a background queue. If no handler is registered with the raven client the message is transmitted straight away.

A handler can be added to the client as follows:

$raven = new \rcrowe\Raven\Client(##DSN##);

$raven->addHandler(
    new \rcrowe\Raven\Handler\Sync
);

Sync Handler

(Default) Like raven-php new messages are transmitted straight away.

Laravel Handler

If using within a Laravel project, makes use of the illuminate\queue API. For improved Laravel intergration checkout the Laravel provider below.

$raven = new \rcrowe\Raven\Client(##DSN##);

$raven->addHandler(
    new \rcrowe\Raven\Handler\Laravel(
        null,
        App::make('queue')
    );
);

Resque Handler

TODO - Will be based around https://github.com/chrisboulton/php-resque

Transports

Transports are responsible for sending the message to the Sentry API. Transports are always the first parameter passed into a handler. If no transport is provided it will default to HTTP.

$raven->addHandler(
    new \rcrowe\Raven\Handler\Sync(
        new \rcrowe\Raven\Transport\Dummy
    )
);
Dummy

Dummy transport does absolutely nothing. Nothing is transmitted to the API. You may not want to transmit to any messages when working in a dev environment.

HTTP

(Default) Transmit the message over HTTP. To do this we make use of the great HTTP client Guzzle.

$raven->addHandler(
    new \rcrowe\Raven\Handler\Sync(
        new \rcrowe\Raven\Transport\Guzzle
    )
);

As this is the default transport mechanism there is no need to pass it into the handler. The above call is the same as:

$raven->addHandler(
    new \rcrowe\Raven\Handler\Sync
);

UDP

TODO

Providers

Providers offer painless integration to other libraries / frameworks.

Laravel

Installation

Raven needs to know your client DSN. First publish the Raven config file with the following command:

php artisan config:publish rcrowe/raven --path vendor/rcrowe/raven/src/Provider/Laravel/config/

Then edit app/config/packages/rcrowe/raven/config.php

Now add the RavenServiceProvider to app/config/app.php:

rcrowe\Raven\Provider\Laravel\RavenServiceProvider

Make sure app/config/queue.php is setup with how you want to connect to your background queue. For further information on working with queues in Laravel checkout their docs.

Usage

Now where ever you want to record a message just use the normal Log facade.

try {
    throw new Exception('This is an example');
} catch (Exception $ex) {
    Log::error($ex);
}

raven's People

Watchers

 avatar  avatar

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.