예제 #1
0
 public function init()
 {
     parent::init();
     if ($this->enabled) {
         $user_context = $this->getUserContext();
         $this->client->user_context($user_context);
         $this->client->install();
     }
 }
예제 #2
0
파일: Logger.php 프로젝트: AltThree/Sentry
 /**
  * Log a message to the logs.
  *
  * @param string $level
  * @param mixed  $message
  * @param array  $context
  *
  * @return void
  */
 public function log($level, $message, array $context = [])
 {
     $this->sentry->context->clear();
     if ($user = $this->resolveCurrentUser()) {
         $this->sentry->user_context($user);
     }
     $this->sentry->extra_context($context);
     $level = $this->getSeverity($level);
     if ($message instanceof Exception) {
         $this->sentry->getIdent($this->sentry->captureException($message, ['level' => $level]));
     } else {
         $msg = $this->formatMessage($message);
         $this->sentry->getIdent($this->sentry->captureMessage($msg, [], ['level' => $level]));
     }
 }
 /**
  * Set user information on the raven context
  */
 protected function setUserContext()
 {
     $objectManager = \TYPO3\Flow\Core\Bootstrap::$staticObjectManager;
     /** @var \TYPO3\Flow\Security\Context $securityContext */
     $securityContext = $objectManager->get('TYPO3\\Flow\\Security\\Context');
     $userContext = array();
     if ($securityContext->isInitialized()) {
         $account = $securityContext->getAccount();
         if ($account !== NULL) {
             $userContext['username'] = $account->getAccountIdentifier();
         }
         $party = $securityContext->getParty();
         if ($party instanceof Person && $party->getPrimaryElectronicAddress() !== NULL) {
             $userContext['email'] = (string) $party->getPrimaryElectronicAddress();
         } elseif ($party !== NULL && ObjectAccess::isPropertyGettable($party, 'emailAddress')) {
             $userContext['email'] = (string) ObjectAccess::getProperty($party, 'emailAddress');
         }
     }
     if ($userContext !== array()) {
         $this->client->user_context($userContext);
     }
 }
예제 #4
0
파일: Flash.php 프로젝트: uzerpllp/uzerp
 /**
  * Send errors to a remote Sentry server with level = warning
  * 
  * @param array $ferrors
  * 
  * @return void
  */
 private function sentrySend($ferrors)
 {
     //ignore if no username or nagios request
     if (EGS_USERNAME or strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'nagios') !== false) {
         try {
             $client = new Raven_Client(SENTRY_DSN, array('curl_method' => 'async', 'verify_ssl' => FALSE));
             // Capture the flash errors and send to Sentry
             $client->user_context(array('username' => EGS_USERNAME));
             $client->tags_context(array('source' => 'flash'));
             $cc = 0;
             foreach ($ferrors as $ferror) {
                 $cc++;
                 $client->extra_context(array('error ' . $cc => $ferror));
             }
             if ($cc != 0) {
                 $event_id = $client->getIdent($client->captureMessage($ferrors[0], array(), 'warning'));
             }
         } catch (Exception $e) {
             //If something went wrong, just continue.
         }
     }
 }
예제 #5
0
 /**
  * Export the message
  *
  * @param array $content Array containing the info about the message
  * @return void
  */
 public function export($content)
 {
     global $conf;
     $dsn = $conf->global->SYSLOG_SENTRY_DSN;
     $client = new Raven_Client($dsn, array('curl_method' => 'exec'));
     $client->user_context(array('username' => $content['user'] ? $content['user'] : '', 'ip_address' => $content['ip']));
     $client->tags_context(array('version' => DOL_VERSION));
     $client->registerSeverityMap(array(LOG_EMERG => Raven_Client::FATAL, LOG_ALERT => Raven_Client::FATAL, LOG_CRIT => Raven_Client::ERROR, LOG_ERR => Raven_Client::ERROR, LOG_WARNING => Raven_Client::WARNING, LOG_NOTICE => Raven_Client::WARNING, LOG_INFO => Raven_Client::INFO, LOG_DEBUG => Raven_Client::DEBUG));
     if (substr($content['message'], 0, 3) === 'sql') {
         global $db;
         $query = substr($content['message'], 4, strlen($content['message']));
         $client->captureQuery($query, $client->translateSeverity($content['level']), $db->type);
     } else {
         $client->captureMessage($content['message'], null, $client->translateSeverity($content['level']));
     }
 }
예제 #6
0
파일: index.php 프로젝트: shomimn/builder
    try {
        $app['settings'] = $app['illuminate.db']->table('settings')->lists('value', 'name');
        $app['settingsJSON'] = json_encode($app['settings']);
    } catch (Exception $e) {
        $app['settings'] = array();
        $app['settingsJSON'] = json_encode($app['settings']);
    }
    require_once __DIR__ . '/backend/builder/routes.php';
}
/*
|--------------------------------------------------------------------------
| Register error handlers
|--------------------------------------------------------------------------
*/
$app->error(function (\Exception $e, $code) use($app) {
    if (!isset($app['base_url'])) {
        $app['base_url'] = rtrim($app['request']->getSchemeAndHttpHost() . $app['request']->getBaseUrl(), '/');
    }
    if ($code === 404) {
        return new Symfony\Component\HttpFoundation\Response($app['twig']->render('404.twig.html'));
    }
    if ($app['is_demo'] && $app['installed']) {
        $user = $app['sentry']->getUser();
        $client = new Raven_Client('');
        if ($user) {
            $client->user_context($user->toArray());
        }
        $client->captureException($e);
    }
});
$app->run();