Ejemplo n.º 1
0
 public function testSetInvalidCurlOptions()
 {
     if (PHP_MAJOR_VERSION >= 7) {
         $this->setExpectedException('TypeError');
     } else {
         $this->setExpectedException('PHPUnit_Framework_Error');
     }
     $this->client->setCurlOptions("option");
 }
Ejemplo n.º 2
0
 /**
  * Writes the record down to the log of the implementing handler
  *
  * @param  array $record
  * @return void
  */
 protected function write(array $record)
 {
     $severity = $this->getSeverity($record['level']);
     if (isset($record['context']['exception'])) {
         $this->client->notifyException($record['context']['exception'], $record, $severity);
     } else {
         $this->client->notifyError($severity, (string) $record['message'], $record, $severity);
     }
 }
 public function register($app)
 {
     /**
      * Bugsnag Register 4bb0c217d0b9cfac312f9d6341b95bff
      */
     $bugsnag = new \Bugsnag_Client("4bb0c217d0b9cfac312f9d6341b95bff");
     $bugsnag->setUser(array('name' => 'RE Damaal', 'email' => '*****@*****.**'));
     set_error_handler(array($bugsnag, "errorHandler"));
     set_exception_handler(array($bugsnag, "exceptionHandler"));
 }
 /**
  * @return Bugsnag_Client
  */
 public static function getBugsnag()
 {
     static $bugsnag = null;
     if (null === $bugsnag) {
         $bugsnag = new \Bugsnag_Client(Configure::read('BugsnagCakephp.apikey'));
         $bugsnag->setBatchSending(false);
         $bugsnag->setNotifier(array('name' => 'Bugsnag CakePHP', 'version' => '0.1.0', 'url' => 'https://github.com/Label305/bugsnag-cakephp'));
     }
     return $bugsnag;
 }
Ejemplo n.º 5
0
 /**
  * Log a message to the logs.
  *
  * @param string $level
  * @param mixed  $message
  * @param array  $context
  *
  * @return void
  */
 public function log($level, $message, array $context = [])
 {
     $severity = $this->getSeverity($level);
     if ($message instanceof Exception) {
         $this->bugsnag->notifyException($message, array_except($context, ['title']), $severity);
     } else {
         $msg = $this->formatMessage($message);
         $title = array_get($context, 'title', str_limit((string) $msg));
         $this->bugsnag->notifyError($title, $msg, array_except($context, ['title']), $severity);
     }
 }
Ejemplo n.º 6
0
 public static function createClient($options = array())
 {
     $bugsnag = new \Bugsnag_Client(Configure::read('BugsnagCakephp.apikey'));
     $bugsnag->setBatchSending(false);
     $bugsnag->setNotifier(array('name' => 'Bugsnag CakePHP', 'version' => '0.1.0', 'url' => 'https://github.com/Label305/bugsnag-cakephp'));
     $bugsnag->setReleaseStage(Configure::read('BugsnagCakephp.releaseStage'));
     $bugsnag->setNotifyReleaseStages(Configure::read('BugsnagCakephp.notifyReleaseStages'));
     $bugsnag->setType("CakePHP");
     $filters = Configure::read('BugsnagCakephp.filters');
     if (!empty($filters)) {
         $bugsnag->setFilters($filters);
     }
     return $bugsnag;
 }
Ejemplo n.º 7
0
 /**
  * Register the bugsnag class.
  *
  * @return void
  */
 protected function registerBugsnag()
 {
     $this->app->singleton('bugsnag', function (Container $app) {
         $bugsnag = new Bugsnag($app->config->get('bugsnag.key'));
         $bugsnag->setStripPath($app->basePath());
         $bugsnag->setProjectRoot($app->path());
         $bugsnag->setAutoNotify(false);
         $bugsnag->setBatchSending(false);
         $bugsnag->setReleaseStage($app->environment());
         $bugsnag->setNotifier(['name' => 'Alt Three Bugsnag PHP', 'version' => '1', 'url' => 'https://alt-three.com']);
         return $bugsnag;
     });
     $this->app->alias('bugsnag', Bugsnag::class);
 }
Ejemplo n.º 8
0
 /**
  * Register the bugsnag class.
  *
  * @return void
  */
 protected function registerBugsnag()
 {
     $this->app->singleton('bugsnag', function ($app) {
         $bugsnag = new Bugsnag($app->config->get('bugsnag.key'));
         $bugsnag->setStripPath($app['path.base']);
         $bugsnag->setProjectRoot($app['path']);
         $bugsnag->setAutoNotify(false);
         $bugsnag->setBatchSending(false);
         $bugsnag->setReleaseStage($app->environment());
         if ($app->auth->check()) {
             $bugsnag->setUser(['id' => $app->auth->user()->getAuthIdentifier()]);
         }
         return $bugsnag;
     });
     $this->app->alias('bugsnag', Bugsnag::class);
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('bugsnag', function ($app) {
         $config = isset($app['config']['services']['bugsnag']) ? $app['config']['services']['bugsnag'] : null;
         if (is_null($config)) {
             $config = $app['config']['bugsnag'] ?: $app['config']['bugsnag::config'];
         }
         $client = new \Bugsnag_Client($config['api_key']);
         $client->setStripPath(base_path());
         $client->setProjectRoot(base_path() . '/app');
         $client->setAutoNotify(false);
         $client->setBatchSending(false);
         $client->setReleaseStage($app->environment());
         $client->setNotifier(array('name' => 'Bugsnag Lumen', 'version' => '1.6.1', 'url' => 'https://github.com/bugsnag/bugsnag-laravel'));
         if (isset($config['notify_release_stages']) && is_array($config['notify_release_stages'])) {
             $client->setNotifyReleaseStages($config['notify_release_stages']);
         }
         if (isset($config['endpoint'])) {
             $client->setEndpoint($config['endpoint']);
         }
         if (isset($config['filters']) && is_array($config['filters'])) {
             $client->setFilters($config['filters']);
         }
         if (isset($config['proxy']) && is_array($config['proxy'])) {
             $client->setProxySettings($config['proxy']);
         }
         // Check if someone is logged in.
         try {
             if ($app['auth']->check()) {
                 // User is logged in.
                 $user = $app['auth']->user();
                 // If these attributes are available: pass them on.
                 $client->setUser(array('id' => $user->getAuthIdentifier()));
             }
         } catch (\Exception $e) {
             // Do nothing.
         }
         return $client;
     });
 }
Ejemplo n.º 10
0
<?php

/*
Plugin Name: Bugsnag
Description: WordPress plugin for tacking errors to Bugsnag
Version: 1.2
Plugin URI: https://github.com/shtrihstr/wp-bugsnag
Author: Oleksandr Strikha
Author URI: https://github.com/shtrihstr
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
if (defined('BUGSNAG_API_KEY')) {
    require_once __DIR__ . '/vendor/autoload.php';
    $bugsnag = new Bugsnag_Client(BUGSNAG_API_KEY);
    $bugsnag->setErrorReportingLevel(E_ERROR | E_PARSE);
    set_error_handler([$bugsnag, 'errorHandler']);
    set_exception_handler([$bugsnag, 'exceptionHandler']);
    add_action('bugsnag_notify', function ($name, $message) use($bugsnag) {
        $bugsnag->notifyError($name, $message);
    }, 1, 2);
}
if (defined('BUGSNAG_FRONTEND_API_KEY') && !is_admin()) {
    add_action('wp_enqueue_scripts', function () {
        wp_enqueue_script('bugsnag', '//d2wy8f7a9ursnm.cloudfront.net/bugsnag-3.min.js');
    }, -1);
    add_filter('script_loader_tag', function ($tag, $handle) {
        if ('bugsnag' == $handle) {
            $tag = str_replace('src=', sprintf("data-apikey='%s' src=", esc_attr(BUGSNAG_FRONTEND_API_KEY)), $tag);
        }
        return $tag;
Ejemplo n.º 11
0
|
*/
App::down(function () {
    return Response::make("Be right back!", 503);
});
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
App::singleton('bugsnag', function () {
    $bugsnag = new Bugsnag_Client(Config::get('app.bugsnag_api_key'));
    $bugsnag->setReleaseStage(App::environment());
    return $bugsnag;
});
App::error(function ($exception) {
    App::make('bugsnag')->notifyException($exception, null, "error");
});
App::fatal(function ($exception) {
    App::make('bugsnag')->notifyException($exception, null, "error");
});
App::make('bugsnag')->setUser(['email' => Auth::check() ? Auth::user()->email : 'Guest user']);
App::make('bugsnag')->setBeforeNotifyFunction(function ($error) {
    $error->setMetaData(["user" => ["username" => Auth::check() ? Auth::user()->username : '******'], "metrics" => ["Metric 1" => "Some data here"]]);
});
require app_path() . '/filters.php';
Ejemplo n.º 12
0
 /**
  * Writes the record down to the log of the implementing handler
  *
  * @param  array $record
  * @return void
  */
 protected function write(array $record)
 {
     $this->bugsnag->notifyError($record['message'], $record['message'], $record['context'], strtolower($record['level_name']));
 }
Ejemplo n.º 13
0
 /**
  * Batches up errors into notifications for later sending
  *
  * @param \Bugsnag_Error $error the error to batch up
  * @param array $metaData optional meta data to send with the error
  * @static 
  */
 public static function notify($error, $metaData = array())
 {
     return \Bugsnag_Client::notify($error, $metaData);
 }
Ejemplo n.º 14
0
 /**
  * Send log to Bugsnag.
  *
  * @param string $level The severity level of the message being written.
  *    See Cake\Log\Log::$_levels for list of possible levels.
  * @param string $message The message you want to log.
  * @param array $context Additional information about the logged message.
  * @return bool success of write.
  */
 public function log($level, $message, array $context = [])
 {
     $level = isset($this->_levels[$level]) ? $this->_levels[$level] : 'info';
     $this->_client->notifyError(ucfirst($level), $message, $context, $level);
 }
Ejemplo n.º 15
0
<?php

require_once "../../build/bugsnag.phar";
$bugsnag = new Bugsnag_Client("066f5ad3590596f9aa8d601ea89af845");
$bugsnag->notifyError("Broken", "Something broke", array("tab" => array("paying" => true, "object" => (object) array("key" => "value"), "null" => NULL, "string" => "test", "int" => 4)));
Ejemplo n.º 16
0
 /**
  * @expectedException PHPUnit_Framework_Error
  */
 public function testSetInvalidCurlOptions()
 {
     $this->client->setCurlOptions("option");
 }
Ejemplo n.º 17
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('bugsnag', function ($app) {
         $config = isset($app['config']['services']['bugsnag']) ? $app['config']['services']['bugsnag'] : null;
         if (is_null($config)) {
             $config = $app['config']['bugsnag'] ?: $app['config']['bugsnag::config'];
         }
         $client = new \Bugsnag_Client($config['api_key']);
         $client->setStripPath(base_path());
         $client->setProjectRoot(base_path() . '/app');
         $client->setAutoNotify(false);
         $client->setBatchSending(true);
         $client->setReleaseStage($app->environment());
         $client->setNotifier(array('name' => 'Bugsnag Lumen', 'version' => '1.6.4', 'url' => 'https://github.com/bugsnag/bugsnag-laravel'));
         if (isset($config['notify_release_stages']) && is_array($config['notify_release_stages'])) {
             $client->setNotifyReleaseStages($config['notify_release_stages']);
         }
         if (isset($config['endpoint'])) {
             $client->setEndpoint($config['endpoint']);
         }
         if (isset($config['filters']) && is_array($config['filters'])) {
             $client->setFilters($config['filters']);
         }
         if (isset($config['proxy']) && is_array($config['proxy'])) {
             $client->setProxySettings($config['proxy']);
         }
         return $client;
     });
 }