Пример #1
0
 public function testDoesFixFrameInfo()
 {
     /**
      * PHP's way of storing backstacks seems bass-ackwards to me
      * 'function' is not the function you're in; it's any function being
      * called, so we have to shift 'function' down by 1. Ugh.
      */
     $stack = raven_test_create_stacktrace();
     $frames = Raven_Stacktrace::get_stack_info($stack, true);
     // just grab the last few frames
     $frames = array_slice($frames, -5);
     $frame = $frames[0];
     $this->assertEquals('StacktraceTest.php:Raven_Tests_StacktraceTest', $frame['module']);
     $this->assertEquals('testDoesFixFrameInfo', $frame['function']);
     $frame = $frames[1];
     $this->assertEquals('StacktraceTest.php', $frame['module']);
     $this->assertEquals('raven_test_create_stacktrace', $frame['function']);
     $frame = $frames[2];
     $this->assertEquals('StacktraceTest.php', $frame['module']);
     $this->assertEquals('raven_test_recurse', $frame['function']);
     $frame = $frames[3];
     $this->assertEquals('StacktraceTest.php', $frame['module']);
     $this->assertEquals('raven_test_recurse', $frame['function']);
     $frame = $frames[4];
     $this->assertEquals('StacktraceTest.php', $frame['module']);
     $this->assertEquals('raven_test_recurse', $frame['function']);
 }
Пример #2
0
 public function capture($data, $stack, $vars = null)
 {
     $event_id = $this->uuid4();
     if (!isset($data['timestamp'])) {
         $data['timestamp'] = gmdate('Y-m-d\\TH:i:s\\Z');
     }
     if (!isset($data['level'])) {
         $data['level'] = self::ERROR;
     }
     $data = array_merge($this->get_default_data(), $data);
     $data['event_id'] = $event_id;
     if ($this->is_http_request()) {
         $data = array_merge($this->get_http_data(), $data);
         $data = array_merge($this->get_user_data(), $data);
     }
     if (!$stack && $this->auto_log_stacks || $stack === True) {
         $stack = debug_backtrace();
         // Drop last stack
         array_shift($stack);
     }
     if (!empty($stack)) {
         if (!isset($data['sentry.interfaces.Stacktrace'])) {
             $data['sentry.interfaces.Stacktrace'] = array('frames' => Raven_Stacktrace::get_stack_info($stack, $this->trace, $this->shift_vars, $vars));
         }
     }
     if (!isset($data['extra'])) {
         $data["extra"] = $this->get_extra_data();
     }
     $this->sanitize($data);
     $this->process($data);
     if (!$this->store_errors_for_bulk_send) {
         $this->send($data);
     } else {
         if (empty($this->error_data)) {
             $this->error_data = array();
         }
         $this->error_data[] = $data;
     }
     return $event_id;
 }
Пример #3
0
 public function capture($data, $stack, $vars = null)
 {
     if (!isset($data['timestamp'])) {
         $data['timestamp'] = gmdate('Y-m-d\\TH:i:s\\Z');
     }
     if (!isset($data['level'])) {
         $data['level'] = self::ERROR;
     }
     if (!isset($data['tags'])) {
         $data['tags'] = array();
     }
     if (!isset($data['extra'])) {
         $data['extra'] = array();
     }
     if (!isset($data['event_id'])) {
         $data['event_id'] = $this->uuid4();
     }
     if (isset($data['message'])) {
         $data['message'] = substr($data['message'], 0, $this->message_limit);
     }
     $data = array_merge($this->get_default_data(), $data);
     if ($this->is_http_request()) {
         $data = array_merge($this->get_http_data(), $data);
     }
     $data = array_merge($this->get_user_data(), $data);
     if ($this->release) {
         $data['release'] = $this->release;
     }
     $data['tags'] = array_merge($this->tags, $this->context->tags, $data['tags']);
     $data['extra'] = array_merge($this->get_extra_data(), $this->context->extra, $data['extra']);
     if (!$stack && $this->auto_log_stacks || $stack === true) {
         $stack = debug_backtrace();
         // Drop last stack
         array_shift($stack);
     }
     if (!empty($stack)) {
         // manually trigger autoloading, as it's not done in some edge cases due to PHP bugs (see #60149)
         if (!class_exists('Raven_Stacktrace')) {
             spl_autoload_call('Raven_Stacktrace');
         }
         if (!isset($data['sentry.interfaces.Stacktrace'])) {
             $data['sentry.interfaces.Stacktrace'] = array('frames' => Raven_Stacktrace::get_stack_info($stack, $this->trace, $this->shift_vars, $vars, $this->message_limit));
         }
     }
     $this->sanitize($data);
     $this->process($data);
     if (!$this->store_errors_for_bulk_send) {
         $this->send($data);
     } else {
         if (empty($this->error_data)) {
             $this->error_data = array();
         }
         $this->error_data[] = $data;
     }
     return $data['event_id'];
 }
Пример #4
0
 public function capture($data, $stack)
 {
     $event_id = $this->uuid4();
     if (!isset($data['timestamp'])) {
         $data['timestamp'] = gmdate('Y-m-d\\TH:i:s\\Z');
     }
     if (!isset($data['level'])) {
         $data['level'] = self::ERROR;
     }
     $data = array_merge($data, array('server_name' => $this->name, 'event_id' => $event_id, 'project' => $this->project, 'site' => $this->site));
     if ($this->is_http_request()) {
         $data = array_merge($data, $this->get_http_data());
         $data = array_merge($data, $this->get_user_data());
     }
     if (!$stack && $this->auto_log_stacks || $stack === True) {
         $stack = debug_backtrace();
         // Drop last stack
         array_shift($stack);
     }
     if (!empty($stack)) {
         if (!isset($data['sentry.interfaces.Stacktrace'])) {
             $data['sentry.interfaces.Stacktrace'] = array('frames' => Raven_Stacktrace::get_stack_info($stack, $this->trace));
         }
     }
     // TODO: allow tags to be specified per event
     $data['tags'] = $this->tags;
     if (empty($data["logger"])) {
         $data["logger"] = 'php';
     }
     if ($extra = $this->get_extra_data()) {
         $data["extra"] = $extra;
     }
     $this->sanitize($data);
     $this->process($data);
     $this->send($data);
     return $event_id;
 }
Пример #5
0
 public function capture($data, $stack)
 {
     $event_id = $this->uuid4();
     if (!isset($data['timestamp'])) {
         $data['timestamp'] = gmdate('Y-m-d\\TH:i:s\\Z');
     }
     if (!isset($data['level'])) {
         $data['level'] = self::ERROR;
     }
     // The function getallheaders() is only available when running in a
     // web-request. The function is missing when run from the commandline..
     $headers = array();
     if (function_exists('getallheaders')) {
         $headers = getallheaders();
         // Don't log cookie information, for security reasons
         $headers['Cookie'] = 'Unset';
     }
     $data = array_merge($data, array('server_name' => $this->name . ' [Zurmo Version: ' . $data['sentry.interfaces.Message']['params']['zurmoVersion'] . ']', 'event_id' => $event_id, 'project' => $this->project, 'site' => $this->site, 'sentry.interfaces.Http' => array('method' => $this->_server_variable('REQUEST_METHOD'), 'url' => $this->get_current_url(), 'query_string' => $this->_server_variable('QUERY_STRNG'), 'data' => $_POST, 'cookies' => array(), 'headers' => $headers, 'env' => $_SERVER)));
     if (!$stack && $this->auto_log_stacks || $stack === True) {
         $stack = debug_backtrace();
         // Drop last stack
         array_shift($stack);
     }
     if (!empty($stack)) {
         /**
          * PHP's way of storing backstacks seems bass-ackwards to me
          * 'function' is not the function you're in; it's any function being
          * called, so we have to shift 'function' down by 1. Ugh.
          */
         for ($i = 0; $i < count($stack) - 1; $i++) {
             $stack[$i]['function'] = $stack[$i + 1]['function'];
         }
         $stack[count($stack) - 1]['function'] = null;
         if (!isset($data['sentry.interfaces.Stacktrace'])) {
             $data['sentry.interfaces.Stacktrace'] = array('frames' => Raven_Stacktrace::get_stack_info($stack));
         }
     }
     if (function_exists('mb_convert_encoding')) {
         $data = $this->remove_invalid_utf8($data);
     }
     $this->send($data);
     return $event_id;
 }
 public function testBasePath()
 {
     $stack = array(array("file" => dirname(__FILE__) . "/resources/a.php", "line" => 11, "function" => "a_test"), array("file" => dirname(__FILE__) . "/resources/b.php", "line" => 3, "function" => "include_once"));
     $frames = Raven_Stacktrace::get_stack_info($stack, true, null, null, 0, array(dirname(__FILE__)));
     $this->assertEquals($frames[0]['filename'], 'resources/b.php');
     $this->assertEquals($frames[1]['filename'], 'resources/a.php');
 }