Loads via the inherited Record class methods.
Author: Drew Butler (drew@dbtlr.com)
Inheritance: extends airbrake\Record
Beispiel #1
0
 /**
  * Convert the notice to xml
  *
  * @param Airbrake\Configuration $configuration
  * @return string
  */
 public function toXml(Configuration $configuration)
 {
     $doc = new SimpleXMLElement('<notice />');
     $doc->addAttribute('version', Version::API);
     $doc->addChild('api-key', $configuration->get('apiKey'));
     $notifier = $doc->addChild('notifier');
     $notifier->addChild('name', Version::NAME);
     $notifier->addChild('version', Version::NUMBER);
     $notifier->addChild('url', Version::APP_URL);
     $env = $doc->addChild('server-environment');
     $env->addChild('project-root', $configuration->get('projectRoot'));
     $env->addChild('environment-name', $configuration->get('environmentName'));
     $error = $doc->addChild('error');
     $error->addChild('class', $this->errorClass);
     $error->addChild('message', htmlspecialchars($this->errorMessage));
     if (count($this->backtrace) > 0) {
         $backtrace = $error->addChild('backtrace');
         foreach ($this->backtrace as $entry) {
             $method = isset($entry['class']) ? $entry['class'] . '::' : '';
             $method .= isset($entry['function']) ? $entry['function'] : '';
             $line = $backtrace->addChild('line');
             $line->addAttribute('file', isset($entry['file']) ? $entry['file'] : '');
             $line->addAttribute('number', isset($entry['line']) ? $entry['line'] : '');
             $line->addAttribute('method', $method);
         }
     }
     $request = $doc->addChild('request');
     $request->addChild('url', $configuration->get('url'));
     $request->addChild('component', $configuration->get('component'));
     $request->addChild('action', $configuration->get('action'));
     $this->array2Node($request, 'params', array_merge($configuration->getParameters(), array('airbrake_extra' => $this->extraParameters)));
     $this->array2Node($request, 'session', $configuration->get('sessionData'));
     $this->array2Node($request, 'cgi-data', $configuration->get('serverData'));
     return $doc->asXML();
 }
 /**
  * Filters out PHP errors before they get sent
  *
  * @param int $type
  * @param string $message
  * @param string $file
  * @param int $line
  * @param array $context
  * @see http://us3.php.net/manual/en/function.set-error-handler.php
  * @return bool
  */
 public function shouldSendError($type, $message, $file = null, $line = null, $context = null)
 {
     $level = $this->config->get('errorReportingLevel');
     if (-1 == $level) {
         return true;
     }
     return $level & $type;
 }
 public function testCustomFilter()
 {
     $initial = array('foo' => 1, 'bar' => 2);
     $expected = array('bar' => 2);
     $instance = new CustomFilter('foo');
     $config = new Configuration('test', array('postData' => $initial));
     $config->addFilter($instance);
     $this->assertEquals($expected, $config->getParameters());
 }
Beispiel #4
0
 /**
  * Get the current handler.
  *
  * @param string $apiKey
  * @param bool $notifyOnWarning
  * @param array $options
  * @return EventHandler
  */
 public static function start($apiKey, $notifyOnWarning = false, array $options = array())
 {
     if (!isset(self::$instance)) {
         $config = new Configuration($apiKey, $options);
         $client = new Client($config);
         self::$instance = new self($client, $notifyOnWarning);
         if (null !== $config->get('errorReportingLevel')) {
             self::$instance->addErrorFilter(new ErrorReporting($config));
         }
         self::$instance->addExceptionFilter(new AirbrakeExceptionFilter());
         set_error_handler(array(self::$instance, 'onError'));
         set_exception_handler(array(self::$instance, 'onException'));
         register_shutdown_function(array(self::$instance, 'onShutdown'));
     }
     return self::$instance;
 }
Beispiel #5
0
 /**
  * Build the Client with the Airbrake Configuration.
  *
  * @throws Airbrake\Exception
  * @param Configuration $configuration
  */
 public function __construct(Configuration $configuration)
 {
     $configuration->verify();
     $this->configuration = $configuration;
     $this->connection = new Connection($configuration);
 }
 /**
  * Class constructor
  *
  * @param string $apiKey
  * @param array|\stdClass $async
  * @param $env
  * @param $host
  * @param $secure
  * @internal param Configuration $configuration
  */
 public function __construct($apiKey, $async, $env, $host, $secure)
 {
     parent::__construct($apiKey, array('async' => $async, 'environmentName' => $env, 'host' => $host, 'secure' => $secure, 'port' => $secure ? 443 : 80));
 }
Beispiel #7
0
 protected function cleanFilePath($filePath)
 {
     $projectRoot = $this->configuration->get('projectRoot');
     return empty($projectRoot) ? $filePath : preg_replace("#^{$projectRoot}#", '[project_root]', $filePath);
 }