当前位置: 首页>>代码示例>>PHP>>正文


PHP Util::logException方法代码示例

本文整理汇总了PHP中OCP\Util::logException方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::logException方法的具体用法?PHP Util::logException怎么用?PHP Util::logException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\Util的用法示例。


在下文中一共展示了Util::logException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: logException

 /**
  * Log exception
  *
  * @internal param Exception $e exception
  */
 public function logException($e)
 {
     $exceptionClass = get_class($e);
     if ($exceptionClass !== 'Sabre_DAV_Exception_NotAuthenticated') {
         \OCP\Util::logException($this->appName, $e);
     }
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:12,代码来源:exceptionloggerplugin.php

示例2: logException

 /**
  * Log exception
  *
  * @internal param Exception $e exception
  */
 public function logException($e)
 {
     $exceptionClass = get_class($e);
     $level = \OCP\Util::FATAL;
     if (isset($this->nonFatalExceptions[$exceptionClass])) {
         $level = \OCP\Util::DEBUG;
     }
     \OCP\Util::logException($this->appName, $e, $level);
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:14,代码来源:exceptionloggerplugin.php

示例3: afterException

 /**
  * If an Exception is being caught, return a JSON error response with
  * a suitable status code
  * @param Controller $controller the controller that is being called
  * @param string $methodName the name of the method that will be called on
  *                           the controller
  * @param \Exception $exception the thrown exception
  * @return Response a Response object
  */
 public function afterException($controller, $methodName, \Exception $exception)
 {
     \OCP\Util::writeLog('contacts', __METHOD__ . ' method: ' . $methodName, \OCP\Util::DEBUG);
     // If there's no proper status code associated, set it to 500.
     $response = new JSONResponse();
     if ($exception->getCode() < 100) {
         $response->setStatus(HttpStatus::STATUS_INTERNAL_SERVER_ERROR);
     } else {
         $response->setStatus($exception->getCode());
     }
     $response->setErrorMessage($exception->getMessage());
     \OCP\Util::logException('contacts', $exception);
     return $response;
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:23,代码来源:http.php

示例4: getFileList

 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  * @SSOCORS
  */
 public function getFileList($dir = null, $sortby = 'name', $sort = false)
 {
     \OCP\JSON::checkLoggedIn();
     \OC::$server->getSession()->close();
     // Load the files
     $dir = $dir ? (string) $dir : '';
     $dir = \OC\Files\Filesystem::normalizePath($dir);
     try {
         $dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
         if (!$dirInfo || !$dirInfo->getType() === 'dir') {
             header('HTTP/1.0 404 Not Found');
             exit;
         }
         $data = array();
         $baseUrl = \OCP\Util::linkTo('files', 'index.php') . '?dir=';
         $permissions = $dirInfo->getPermissions();
         $sortDirection = $sort === 'desc';
         $mimetypeFilters = '';
         $files = [];
         if (is_array($mimetypeFilters) && count($mimetypeFilters)) {
             $mimetypeFilters = array_unique($mimetypeFilters);
             if (!in_array('httpd/unix-directory', $mimetypeFilters)) {
                 $mimetypeFilters[] = 'httpd/unix-directory';
             }
             foreach ($mimetypeFilters as $mimetypeFilter) {
                 $files = array_merge($files, \OCA\Files\Helper::getFiles($dir, $sortby, $sortDirection, $mimetypeFilter));
             }
             $files = \OCA\Files\Helper::sortFiles($files, $sortby, $sortDirection);
         } else {
             $files = \OCA\Files\Helper::getFiles($dir, $sortby, $sortDirection);
         }
         $files = \OCA\Files\Helper::populateTags($files);
         $data['directory'] = $dir;
         $data['files'] = \OCA\Files\Helper::formatFileInfos($files);
         $data['permissions'] = $permissions;
         return new DataResponse(array('data' => $data, 'status' => 'success'));
     } catch (\OCP\Files\StorageNotAvailableException $e) {
         \OCP\Util::logException('files', $e);
         return new DataResponse(array('data' => array('exception' => '\\OCP\\Files\\StorageNotAvailableException', 'message' => 'Storage not available'), 'status' => 'error'));
     } catch (\OCP\Files\StorageInvalidException $e) {
         \OCP\Util::logException('files', $e);
         return new DataResponse(array('data' => array('exception' => '\\OCP\\Files\\StorageInvalidException', 'message' => 'Storage invalid'), 'status' => 'error'));
     } catch (\Exception $e) {
         \OCP\Util::logException('files', $e);
         return new DataResponse(array('data' => array('exception' => '\\Exception', 'message' => 'Unknown error'), 'status' => 'error'));
     }
 }
开发者ID:inwinstack,项目名称:owncloud-singlesignon,代码行数:52,代码来源:collaborationapicontroller.php

示例5: checkDatabaseVersion

 /**
  * Check the database version
  *
  * @return array errors array
  */
 public static function checkDatabaseVersion()
 {
     $l = \OC::$server->getL10N('lib');
     $errors = array();
     $dbType = \OC_Config::getValue('dbtype', 'sqlite');
     if ($dbType === 'pgsql') {
         // check PostgreSQL version
         try {
             $result = \OC_DB::executeAudited('SHOW SERVER_VERSION');
             $data = $result->fetchRow();
             if (isset($data['server_version'])) {
                 $version = $data['server_version'];
                 if (version_compare($version, '9.0.0', '<')) {
                     $errors[] = array('error' => $l->t('PostgreSQL >= 9 required'), 'hint' => $l->t('Please upgrade your database version'));
                 }
             }
         } catch (\Doctrine\DBAL\DBALException $e) {
             \OCP\Util::logException('core', $e);
             $errors[] = array('error' => $l->t('Error occurred while checking PostgreSQL version'), 'hint' => $l->t('Please make sure you have PostgreSQL >= 9 or' . ' check the logs for more information about the error'));
         }
     }
     return $errors;
 }
开发者ID:pinoniq,项目名称:core,代码行数:28,代码来源:util.php

示例6: handleLogin

 protected static function handleLogin()
 {
     OC_App::loadApps(array('prelogin'));
     $error = array();
     $messages = [];
     try {
         // auth possible via apache module?
         if (OC::tryApacheAuth()) {
             $error[] = 'apacheauthfailed';
         } elseif (OC::tryRememberLogin()) {
             $error[] = 'invalidcookie';
         } elseif (OC::tryFormLogin()) {
             $error[] = 'invalidpassword';
         }
     } catch (\OC\User\LoginException $e) {
         $messages[] = $e->getMessage();
     } catch (\Exception $ex) {
         \OCP\Util::logException('handleLogin', $ex);
         // do not disclose information. show generic error
         $error[] = 'internalexception';
     }
     OC_Util::displayLoginPage(array_unique($error), $messages);
 }
开发者ID:krsvital,项目名称:core,代码行数:23,代码来源:base.php

示例7: upgrade

	/**
	 * runs the update actions in maintenance mode, does not upgrade the source files
	 * except the main .htaccess file
	 *
	 * @return bool true if the operation succeeded, false otherwise
	 */
	public function upgrade() {
		$wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);

		if(!$wasMaintenanceModeEnabled) {
			$this->config->setSystemValue('maintenance', true);
			$this->emit('\OC\Updater', 'maintenanceEnabled');
		}

		$installedVersion = $this->config->getSystemValue('version', '0.0.0');
		$currentVersion = implode('.', \OC_Util::getVersion());
		if ($this->log) {
			$this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
		}

		$success = true;
		try {
			$this->doUpgrade($currentVersion, $installedVersion);
		} catch (\Exception $exception) {
			\OCP\Util::logException('update', $exception);
			$this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage()));
			$success = false;
		}

		$this->emit('\OC\Updater', 'updateEnd', array($success));

		if(!$wasMaintenanceModeEnabled && $success) {
			$this->config->setSystemValue('maintenance', false);
			$this->emit('\OC\Updater', 'maintenanceDisabled');
		} else {
			$this->emit('\OC\Updater', 'maintenanceActive');
		}

		return $success;
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:40,代码来源:updater.php

示例8: catch

 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
// Show warning if a PHP version below 5.4.0 is used, this has to happen here
// because base.php will already use 5.4 syntax.
if (version_compare(PHP_VERSION, '5.4.0') === -1) {
    echo 'This version of ownCloud requires at least PHP 5.4.0<br/>';
    echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.';
    return;
}
try {
    require_once 'lib/base.php';
    OC::handleRequest();
} catch (\OC\ServiceUnavailableException $ex) {
    \OCP\Util::logException('index', $ex);
    //show the user a detailed error page
    OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
    OC_Template::printExceptionErrorPage($ex);
} catch (\OC\HintException $ex) {
    OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
    OC_Template::printErrorPage($ex->getMessage(), $ex->getHint());
} catch (Exception $ex) {
    \OCP\Util::logException('index', $ex);
    //show the user a detailed error page
    OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
    OC_Template::printExceptionErrorPage($ex);
}
开发者ID:loulancn,项目名称:core,代码行数:31,代码来源:index.php

示例9: writeBack

 public function writeBack($tmpFile)
 {
     if (!isset(self::$tmpFiles[$tmpFile])) {
         return false;
     }
     try {
         $this->getConnection()->putObject(array('Bucket' => $this->bucket, 'Key' => $this->cleanKey(self::$tmpFiles[$tmpFile]), 'SourceFile' => $tmpFile, 'ContentType' => \OC::$server->getMimeTypeDetector()->detect($tmpFile), 'ContentLength' => filesize($tmpFile)));
         $this->testTimeout();
         unlink($tmpFile);
     } catch (S3Exception $e) {
         \OCP\Util::logException('files_external', $e);
         return false;
     }
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:14,代码来源:amazons3.php

示例10: catch

            }
        }
    } catch (\Exception $e) {
        \OCP\Util::writeLog('filefilter', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
        return false;
    }
    //将tags赋值给files数组
    if (isset($entries)) {
        foreach ($entries as $fileId => $fileTags) {
            $filesById[$fileId]['tags'] = $fileTags;
        }
    }
    //将最后值变为filelist
    foreach ($filesById as $val) {
        $filelist[] = $val;
    }
    $data['directory'] = $dir;
    $data['files'] = $filelist;
    //\OCA\Files\Helper::formatFileInfos($files);
    $data['permissions'] = (int) $permissions;
    OCP\JSON::success(array('data' => $data));
} catch (\OCP\Files\StorageNotAvailableException $e) {
    \OCP\Util::logException('files', $e);
    OCP\JSON::error(array('data' => array('exception' => '\\OCP\\Files\\StorageNotAvailableException', 'message' => $l->t('Storage not available'))));
} catch (\OCP\Files\StorageInvalidException $e) {
    \OCP\Util::logException('files', $e);
    OCP\JSON::error(array('data' => array('exception' => '\\OCP\\Files\\StorageInvalidException', 'message' => $l->t('Storage invalid'))));
} catch (\Exception $e) {
    \OCP\Util::logException('files', $e);
    OCP\JSON::error(array('data' => array('exception' => '\\Exception', 'message' => $l->t('Unknown error'))));
}
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:31,代码来源:list.php

示例11: getBackendStatus

 /**
  * Test connecting using the given backend configuration
  *
  * @param string $class backend class name
  * @param array $options backend configuration options
  * @return int see self::STATUS_*
  */
 public static function getBackendStatus($class, $options, $isPersonal)
 {
     if (self::$skipTest) {
         return self::STATUS_SUCCESS;
     }
     foreach ($options as &$option) {
         $option = self::setUserVars(OCP\User::getUser(), $option);
     }
     if (class_exists($class)) {
         try {
             $storage = new $class($options);
             if ($storage->test($isPersonal)) {
                 return self::STATUS_SUCCESS;
             }
         } catch (Exception $exception) {
             \OCP\Util::logException('files_external', $exception);
         }
     }
     return self::STATUS_ERROR;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:27,代码来源:config.php

示例12: handleLogin

 protected static function handleLogin()
 {
     OC_App::loadApps(array('prelogin'));
     $error = array();
     $messages = [];
     try {
         // auth possible via apache module?
         if (OC::tryApacheAuth()) {
             $error[] = 'apacheauthfailed';
         } elseif (OC::tryRememberLogin()) {
             $error[] = 'invalidcookie';
         } elseif (OC::tryFormLogin()) {
             $error[] = 'invalidpassword';
         }
     } catch (\OC\User\LoginException $e) {
         $messages[] = $e->getMessage();
     } catch (\Exception $ex) {
         \OCP\Util::logException('handleLogin', $ex);
         // do not disclose information. show generic error
         $error[] = 'internalexception';
     }
     if (!\OC::$server->getUserSession()->isLoggedIn()) {
         $loginMessages = array(array_unique($error), $messages);
         \OC::$server->getSession()->set('loginMessages', $loginMessages);
         // Read current user and append if possible
         $args = [];
         if (isset($_POST['user'])) {
             $args['user'] = $_POST['user'];
         }
         $redirectionTarget = \OC::$server->getURLGenerator()->linkToRoute('core.login.showLoginForm', $args);
         header('Location: ' . $redirectionTarget);
     }
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:33,代码来源:base.php

示例13: upgrade

 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  * except the main .htaccess file
  *
  * @return bool true if the operation succeeded, false otherwise
  */
 public function upgrade()
 {
     $logLevel = \OC_Config::getValue('loglevel', \OCP\Util::WARN);
     $this->emit('\\OC\\Updater', 'setDebugLogLevel', array($logLevel, $this->logLevelNames[$logLevel]));
     \OC_Config::setValue('loglevel', \OCP\Util::DEBUG);
     \OC_DB::enableCaching(false);
     \OC_Config::setValue('maintenance', true);
     $installedVersion = \OC_Config::getValue('version', '0.0.0');
     $currentVersion = implode('.', \OC_Util::getVersion());
     if ($this->log) {
         $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
     }
     $this->emit('\\OC\\Updater', 'maintenanceStart');
     $success = true;
     try {
         $this->doUpgrade($currentVersion, $installedVersion);
     } catch (\Exception $exception) {
         \OCP\Util::logException('update', $exception);
         $this->emit('\\OC\\Updater', 'failure', array(get_class($exception) . ': ' . $exception->getMessage()));
         $success = false;
     }
     \OC_Config::setValue('maintenance', false);
     $this->emit('\\OC\\Updater', 'maintenanceEnd');
     $this->emit('\\OC\\Updater', 'updateEnd', array($success));
     $this->emit('\\OC\\Updater', 'resetLogLevel', array($logLevel, $this->logLevelNames[$logLevel]));
     \OC_Config::setValue('loglevel', $logLevel);
     return $success;
 }
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:34,代码来源:updater.php

示例14: getBackendStatus

 /**
  * Test connecting using the given backend configuration
  * @param string $class backend class name
  * @param array $options backend configuration options
  * @return bool true if the connection succeeded, false otherwise
  */
 private static function getBackendStatus($class, $options, $isPersonal)
 {
     if (self::$skipTest) {
         return true;
     }
     foreach ($options as &$option) {
         $option = self::setUserVars(OCP\User::getUser(), $option);
     }
     if (class_exists($class)) {
         try {
             $storage = new $class($options);
             return $storage->test($isPersonal);
         } catch (Exception $exception) {
             \OCP\Util::logException('files_external', $exception);
             return false;
         }
     }
     return false;
 }
开发者ID:Romua1d,项目名称:core,代码行数:25,代码来源:config.php

示例15: initSession

 public static function initSession()
 {
     // prevents javascript from accessing php session cookies
     ini_set('session.cookie_httponly', true);
     // set the cookie path to the ownCloud directory
     $cookie_path = OC::$WEBROOT ?: '/';
     ini_set('session.cookie_path', $cookie_path);
     // Let the session name be changed in the initSession Hook
     $sessionName = OC_Util::getInstanceId();
     try {
         // Allow session apps to create a custom session object
         $useCustomSession = false;
         $session = self::$server->getSession();
         OC_Hook::emit('OC', 'initSession', array('session' => &$session, 'sessionName' => &$sessionName, 'useCustomSession' => &$useCustomSession));
         if (!$useCustomSession) {
             // set the session name to the instance id - which is unique
             $session = new \OC\Session\Internal($sessionName);
         }
         $cryptoWrapper = \OC::$server->getSessionCryptoWrapper();
         $session = $cryptoWrapper->wrapSession($session);
         self::$server->setSession($session);
         // if session can't be started break with http 500 error
     } catch (Exception $e) {
         \OCP\Util::logException('base', $e);
         //show the user a detailed error page
         OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
         OC_Template::printExceptionErrorPage($e);
         die;
     }
     $sessionLifeTime = self::getSessionLifeTime();
     // session timeout
     if ($session->exists('LAST_ACTIVITY') && time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime) {
         if (isset($_COOKIE[session_name()])) {
             setcookie(session_name(), null, -1, self::$WEBROOT ?: '/');
         }
         \OC::$server->getUserSession()->logout();
     }
     $session->set('LAST_ACTIVITY', time());
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:39,代码来源:base.php


注:本文中的OCP\Util::logException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。