/** * {@inheritdoc} */ public function export() { foreach ($this->messages as $message) { list($context, $level, $category, $timestamp, $traces) = $message; $extra = []; if ($context instanceof \Throwable || $context instanceof \Exception) { $this->client->captureException($context); $description = $context->getMessage(); } elseif (isset($context['msg'])) { $description = $context['msg']; $extra = $context; unset($extra['msg']); } else { $description = $context; } if ($this->context) { $extra['context'] = parent::getContextMessage(); } if (is_callable($this->extraCallback)) { $extra = call_user_func($this->extraCallback, $context, $extra); } $data = ['level' => static::getLevelName($level), 'timestamp' => $timestamp, 'message' => $description, 'extra' => $extra, 'tags' => ['category' => $category]]; $this->client->capture($data, $traces); } }
/** * Exports log [[messages]] to a specific destination. */ public function export() { foreach ($this->messages as $message) { list($msg, $level, $category, $timestamp, $traces) = $message; $levelName = Logger::getLevelName($level); if (!in_array($levelName, ['error', 'warning', 'info'])) { $levelName = 'error'; } $data = ['timestamp' => gmdate('Y-m-d\\TH:i:s\\Z', $timestamp), 'level' => $levelName, 'tags' => ['category' => $category], 'message' => $msg]; if (!empty($traces)) { $data['sentry.interfaces.Stacktrace'] = ['frames' => Raven_Stacktrace::get_stack_info($traces)]; } $this->client->capture($data, false); } }
public function capture($data, $stack, $vars = null) { // if (class_exists('AuthComponent')) { // $model= Configure::read('Sentry.User.model'); // if (empty($model)) $model = 'User'; // $User = ClassRegistry::init($model); // $mail = Configure::read('Sentry.User.email_field'); // if (empty($mail)) { // if ($User->hasField('email')) $mail = 'email'; // else if ($User->hasField('mail')) $mail = 'mail'; // } // $data['sentry.interfaces.User'] = array( // "is_authenticated" => AuthComponent::user($User->primaryKey) ? true : false, // "id" => AuthComponent::user($User->primaryKey), // "username" => AuthComponent::user($User->displayField), // "email" => AuthComponent::user($mail) // ); // } return parent::capture($data, $stack); }
public function capture($data, $stack, $vars = NULL) { if (class_exists('AuthComponent')) { $model = Configure::read('Sentry.User.model'); if (empty($model)) { $model = 'User'; } $User = ClassRegistry::init($model); $mail = Configure::read('Sentry.User.email_field'); if (empty($mail)) { if ($User->hasField('email')) { $mail = 'email'; } else { if ($User->hasField('mail')) { $mail = 'mail'; } } } $data['sentry.interfaces.User'] = array("is_authenticated" => AuthComponent::user($User->primaryKey) ? true : false, "id" => AuthComponent::user($User->primaryKey), "username" => AuthComponent::user($User->displayField), "email" => AuthComponent::user($mail)); } return parent::capture($data, $stack); }
/** * Log a message to sentry */ public function capture($data, $stack) { if (!Mage::getStoreConfigFlag('dev/amg-sentry/active')) { return true; } if (!empty($data['sentry.interfaces.Message']['params']['description'])) { $data['culprit'] = $data['message']; $data['message'] = $data['sentry.interfaces.Message']['params']['description']; unset($data['sentry.interfaces.Message']['params']['description']); } if (!empty($data['sentry.interfaces.Exception']['value'])) { $data['message'] = $data['culprit']; $data['culprit'] = $data['sentry.interfaces.Exception']['value']; } if (!isset($data['logger'])) { if (null !== self::$_logger) { $data['logger'] = self::$_logger; } else { $data['logger'] = Mage::getStoreConfig('dev/amg-sentry/logger'); } } return parent::capture($data, $stack); }
/** * Exports log [[messages]] to a specific destination. */ public function export() { foreach ($this->messages as $message) { list($msg, $level, $category, $timestamp, $traces) = $message; $levelName = Logger::getLevelName($level); if (!in_array($levelName, ['error', 'warning', 'info'])) { $levelName = 'error'; } if (is_array($msg)) { if (isset($msg['data'])) { $new_extras = $msg['data']; unset($msg['data']); } if (isset($msg['msg'])) { $new_msg = $msg['msg']; unset($msg['msg']); } else { $new_msg = 'Unknown event format'; // deliver event data even if the format doesn't fit $new_extras = array_merge($new_extras, $msg); $new_tags = ['format' => 'unknown']; } } $data = ['timestamp' => gmdate('Y-m-d\\TH:i:s\\Z', $timestamp), 'level' => $levelName, 'tags' => ['category' => $category], 'message' => isset($new_msg) ? $new_msg : $msg]; if (isset($new_tags)) { $data['tags'] = array_merge($new_tags, $this->client->get_tags(), $this->client->context->extra); } if (isset($new_extras)) { $data['extra'] = array_merge($new_extras, $this->client->tags, $this->client->context->tags); } if (!empty($traces)) { $data['sentry.interfaces.Stacktrace'] = ['frames' => Raven_Stacktrace::get_stack_info($traces)]; } $this->client->capture($data, false); } }