Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
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.º 3
0
/*
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;
    }, 5, 2);
}
Ejemplo n.º 4
0
 public function testManualErrorNotification()
 {
     $this->client->expects($this->once())->method('notify');
     $this->client->notifyError("SomeError", "Some message");
 }
Ejemplo n.º 5
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.º 6
0
 /**
  * Notify Bugsnag of a non-fatal/handled error
  *
  * @param String $errorName the name of the error, a short (1 word) string
  * @param String $errorMessage the error message
  * @param Array $metaData optional metaData to send with this error
  * @param String $severity optional severity of this error (fatal/error/warning/info)
  * @static 
  */
 public static function notifyError($name, $message, $metaData = null, $severity = null)
 {
     return \Bugsnag_Client::notifyError($name, $message, $metaData, $severity);
 }
Ejemplo n.º 7
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.º 8
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)));