コード例 #1
0
 /**
  * Log exception
  *
  */
 public function logException(\Exception $ex)
 {
     $exceptionClass = get_class($ex);
     $level = \OCP\Util::FATAL;
     if (isset($this->nonFatalExceptions[$exceptionClass])) {
         $level = \OCP\Util::DEBUG;
     }
     $message = $ex->getMessage();
     if ($ex instanceof Exception) {
         if (empty($message)) {
             $response = new Response($ex->getHTTPCode());
             $message = $response->getStatusText();
         }
         $message = "HTTP/1.1 {$ex->getHTTPCode()} {$message}";
     }
     $exception = ['Message' => $message, 'Code' => $ex->getCode(), 'Trace' => $ex->getTraceAsString(), 'File' => $ex->getFile(), 'Line' => $ex->getLine()];
     $this->logger->log($level, 'Exception: ' . json_encode($exception), ['app' => $this->appName]);
 }
コード例 #2
0
ファイル: ocsauthapi.php プロジェクト: kenwi/core
 /**
  * create shared secret and return it
  *
  * @return \OC_OCS_Result
  */
 public function getSharedSecret()
 {
     $url = $this->request->getParam('url');
     $token = $this->request->getParam('token');
     if ($this->trustedServers->isTrustedServer($url) === false) {
         $this->logger->log(\OCP\Util::ERROR, 'remote server not trusted (' . $url . ') while getting shared secret');
         return new \OC_OCS_Result(null, HTTP::STATUS_FORBIDDEN);
     }
     if ($this->isValidToken($url, $token) === false) {
         $this->logger->log(\OCP\Util::ERROR, 'remote server (' . $url . ') didn\'t send a valid token (got ' . $token . ') while getting shared secret');
         return new \OC_OCS_Result(null, HTTP::STATUS_FORBIDDEN);
     }
     $sharedSecret = $this->secureRandom->generate(32);
     $this->trustedServers->addSharedSecret($url, $sharedSecret);
     // reset token after the exchange of the shared secret was successful
     $this->dbHandler->addToken($url, '');
     return new \OC_OCS_Result(['sharedSecret' => $sharedSecret], Http::STATUS_OK);
 }
コード例 #3
0
ファイル: logger.php プロジェクト: matiasdelellis/mail
 /**
  * @inheritdoc
  */
 public function log($level, $message, array $context = array())
 {
     $this->logger->log($level, $message, array_merge($this->context, $context));
 }
コード例 #4
0
 private function log($level, $message, $params)
 {
     $msg = vsprintf($message, $params);
     $this->logger->log($level, $msg, ['app' => $this->loggerName]);
 }