本文整理汇总了PHP中App::log方法的典型用法代码示例。如果您正苦于以下问题:PHP App::log方法的具体用法?PHP App::log怎么用?PHP App::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: diagnosticAction
public function diagnosticAction()
{
if (!$this->getRequest()->isGet()) {
throw new UnexpectedException("Resquest must be GET");
}
$transactionId = $this->_getTransactionId();
try {
$result = $this->_service->load($transactionId);
if ($result->status == WatcherModel::STATUS_FINISHED) {
// Check permissions
$this->_helper->allowed('read', $result);
$events = $result->getEventList();
$event = array_pop($events);
// Return async response
$data = $event->eventData;
$code = $data['message']['execResult']['code'];
$reason = $data['message']['execResult']['reason'];
if ($code == "0") {
$this->view->result = $reason;
} else {
$this->view->AsyncException = new External\Model\AsyncErrorModel(array('exceptionId' => $code, 'text' => $reason));
}
}
} catch (Exception $e) {
\App::log()->warn($e);
}
}
示例2: authenticate
/**
* Performs an authentication attempt
*
* @throws Zend_Auth_Adapter_Exception If authentication cannot be performed
* @return Zend_Auth_Result
*/
public function authenticate()
{
if (empty($this->_request) || empty($this->_response)) {
require_once 'Zend/Auth/Adapter/Exception.php';
throw new Zend_Auth_Adapter_Exception('Request and Response objects must be set before calling ' . 'authenticate()');
}
$header = $this->_request->getHeader('Authorization');
if (empty($header)) {
return $this->_challengeClient();
}
$parts = array_filter(explode(' ', $header));
if ($parts < 2) {
return $this->_challengeClient();
}
$scheme = array_shift($parts);
$creds = implode(' ', $parts);
if (empty($this->_schemes[$scheme])) {
throw new Zend_Auth_Adapter_Exception('Unsupported authentication scheme (' . $scheme . ')');
}
$result = call_user_func($this->_schemes[$scheme], trim($creds), $this->_request);
if (empty($result)) {
\App::log()->debug("Authentication failed using scheme: " . @$this->_schemes[$scheme]);
\App::log()->debug("Authentication failed using creds: " . @$creds);
return $this->_challengeClient();
} else {
if ($result instanceof Zend_Auth_Result) {
return $result;
} else {
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $result);
}
}
}
示例3: isValid
public function isValid($value)
{
if (!$this->getType()) {
throw new Application\Exceptions\InvalidArgumentException('Not organization type defined.');
}
if (is_string($value)) {
try {
$newValue = Application\Service\OrgService::getInstance()->getTypeById($value);
} catch (Exception $e) {
\App::log()->warn($e);
$this->_error(self::INVALID_DATA, $value);
return false;
}
} else {
if ($value instanceof Application\Model\OrgModelAbstract) {
$newValue = $value::ORG_TYPE;
}
}
if (!is_string($value) || !$newValue) {
$this->_error(self::INVALID_DATA, $newValue);
return false;
}
if ($newValue != $this->getType()) {
$this->_error(self::NOT_VALID_ORG_TYPE, $newValue);
return false;
}
return true;
}
示例4: diagnosticAction
public function diagnosticAction()
{
if (!$this->getRequest()->isGet()) {
throw new UnexpectedException("Resquest must be GET");
}
$transactionId = $this->_getTransactionId();
$result = $this->_service->load($transactionId);
if (!$result) {
throw new NotFoundException("Resource {$transactionId} not found");
}
try {
if ($result->status == WatcherModel::STATUS_FINISHED) {
// Check permissions
$this->_helper->allowed('read', $result);
$events = $result->getEventList();
$event = array_pop($events);
// Return async response
$data = $event->eventData;
$code = $data['message']['execResult']['code'];
$reason = $data['message']['execResult']['reason'];
if ($code == "0") {
$this->view->result = $reason;
} else {
$this->view->result = "ERROR";
$this->view->reason = "[{$code}] " . $reason;
}
}
} catch (Exception $e) {
\App::log()->warn($e);
}
}
示例5: dispatchLoopStartup
/**
* Route shutdown hook -- Check for router exceptions
*
* @param Zend_Controller_Request_Abstract $request
*/
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
$auth = Zend_Auth::getInstance();
$orgService = \Application\Service\OrgService::getInstance();
$identity = $auth->getIdentity();
//Bypass other auth methods
if ($identity['authType'] != App_Controller_Plugin_Auth::AUTH_TYPE_AUTH_TOKEN) {
return;
}
$front = Zend_Controller_Front::getInstance();
$bs = $front->getParam('bootstrap');
// Fetch logs and apply the token to them
$multilog = $bs->getPluginResource('multiplelog');
if (empty($identity['impersonation']) || empty($identity['impersonation']['orgId'])) {
return;
}
$orgId = $identity['impersonation']['orgId'];
$userSrv = UserService::getInstance();
\App::log()->info($identity['username'] . " is running as " . $orgId . " admin");
$user = $userSrv->loadByUsername($identity['username']);
$userSrv->generateImpersonatedUser($user, $identity['impersonation']);
foreach ($multilog->getLogs() as $log) {
$log->setEventItem('impersonated', "as {$orgId} admin");
$log->setEventItem('impersonatedOrgId', "{$orgId}");
$log->setEventItem('username', $identity['username'] . " as {$orgId} admin");
}
// Application\Model\Mapper\ProtoAbstractMapper::$accountingUserId .= "_impersonated";
Application\Model\Mapper\ProtoAbstractMapper::$organizationId = $orgId;
App_ListFilter::addDefaultExtraData('impersonated_org', $orgId);
$org = OrgService::getInstance()->load($orgId);
\App::getOrgUserLogged($org);
}
示例6: create
/**
* Perform backup
* @return string
*/
public static function create()
{
$collection = new Collection();
$locations = Helper::getPreparedLocations();
foreach ($locations as $type => $dirs) {
foreach ($dirs as $name => $path) {
Helper::checkr($path, $collection);
}
}
if (count($collection->getNotReadable()) || count($collection->getNotWritable())) {
$e = new PermissionException();
$e->setCollection($collection);
throw $e;
}
try {
Helper::mkdir(self::getPath(), true);
foreach ($locations as $type => $dirs) {
$backupFullPath = self::getPath() . '/' . $type . '/';
Helper::mkdir($backupFullPath, true);
foreach ($dirs as $name => $path) {
Helper::copyr($path, $backupFullPath . $name);
}
}
} catch (\Exception $e) {
App::log('Backup creation failed. Disk full?');
self::cleanUp();
throw new FsException($e->getMessage());
}
return self::getPath();
}
示例7: forceExit
public function forceExit()
{
if (APPLICATION_ENV != "testing") {
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
}
$plugins = Zend_Controller_Front::getInstance()->getPlugins();
$broker = new Zend_Controller_Plugin_Broker();
$broker->setRequest(Zend_Controller_Front::getInstance()->getRequest());
$broker->setResponse(Zend_Controller_Front::getInstance()->getResponse());
foreach ($plugins as $index => $plugin) {
$broker->registerPlugin($plugin, $index);
}
try {
$broker->postDispatch($broker->getRequest());
} catch (Exception $e) {
\App::log()->crit('Error executing "postDispatch" after stream');
\App::log()->crit($e);
}
try {
$broker->dispatchLoopShutdown();
} catch (Exception $e) {
\App::log()->crit('Error executing "dispatchLoopShutdown" after stream');
\App::log()->crit($e);
}
if (APPLICATION_ENV !== 'testing') {
exit;
}
}
示例8: direct
/**
* @throws ForbiddenException
* @throws Zend_Controller_Exception
* @param string $privilege
* @param \Application\Model\ModelAbstract $resource
*/
public function direct($privilege = null, $resource = null)
{
if ($privilege && $resource instanceof App_ListFilter_CollectionAbstract) {
$default = $this->_getDefault($privilege, $resource);
if ($default !== NULL) {
foreach ($resource->getFilters() as $filter) {
$field = $filter->getFieldName();
try {
$pr = $privilege . "_" . $field;
if ($default && !$this->_privilegeExists($pr, $resource)) {
continue;
}
$this->_allowed($pr, $resource);
} catch (Exception $exc) {
if ($this->getThrowExOnNotAllowed()) {
throw new NotAllowedException("User has no permission to filter by {$field}");
}
\App::log()->debug("User has no permission to filter by {$field}");
$resource->removeFiltersByFieldName($field);
}
}
}
}
return $this;
}
示例9: dispatchLoopStartup
/**
* Route shutdown hook -- Check for router exceptions
*
* @param Zend_Controller_Request_Abstract $request
*/
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
try {
if ($request->getControllerName() == 'error') {
return;
}
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()) {
return;
}
$identity = $auth->getIdentity();
if (!isset($identity['authType'])) {
$this->_forceLogout($request, "Unexpected fatal error: Unknown auth method.", 500);
return;
}
if (!isset(self::$zones[$identity['authType']])) {
self::$zones[$identity['authType']] = array();
}
if (!$this->_checkAllowedZone(self::$zones[$identity['authType']], $request->getModuleName(), $request->getControllerName(), $request->getActionName())) {
$this->_forceLogout($request, $identity['authType'] . " not allowed to access to module '" . $request->getModuleName() . "', controller '" . $request->getControllerName() . "', action '" . $request->getActionName() . "'.");
}
} catch (Exception $exc) {
\App::log()->err($exc);
$this->_forceLogout($request, "Unexpected fatal error: " . $exc->getMessage(), 500);
}
}
示例10: performUpgrade
public static function performUpgrade()
{
\App::log()->info("Retriving life cycle templates.");
$mapper = TemplateMapper::getInstance();
try {
$templateList = self::retrieveLifeCycleTemplates();
} catch (Exception $e) {
\App::log()->info($e->getMessage());
\App::log()->info("Error retriving life cycle templates. Aborting templates upgrade.");
return;
}
\App::log()->info($templateList->getCount() . " templates to upgrade.");
foreach ($templateList->getItems() as $template) {
try {
\App::log()->info("Upgrading life cycle template " . $template->id . "...");
$lifeCycle = self::upgradeLifeCycle($template);
$mapper->update(self::upgradeLifeCycleTemplate($template, $lifeCycle));
\App::log()->info("Template " . $template->id . " upgraded succefully.");
} catch (App_MigrationTool_TemplatesTo24_Exception $e) {
\App::log()->info($e->getMessage());
}
}
\App::log()->info("Life cycle templates upgraded succefully.");
return true;
}
示例11: isValid
public function isValid($value)
{
$this->_messages = array();
try {
$org = OrgService::getInstance()->load($value);
} catch (Application\Exceptions\InvalidArgumentException $e) {
\App::log()->info($e);
$message = $this->_createMessage(self::ERROR_INVALID_ORG_TYPE, $value);
$this->_messages[self::ERROR_INVALID_ORG_TYPE] = $message;
return false;
} catch (Application\Exceptions\GlobalServiceException $e) {
\App::log()->info($e);
$message = $this->_createMessage(self::ERROR_ON_CONNECTION, $value);
$this->_messages[self::ERROR_ON_CONNECTION] = $message;
return false;
}
if (!isset($org)) {
$message = $this->_createMessage(self::ERROR_ORGANIZATION_NOT_FOUND, $value);
$this->_messages[self::ERROR_ORGANIZATION_NOT_FOUND] = $message;
return false;
}
if (!is_string($org->getType())) {
$message = $this->_createMessage(self::ERROR_INVALID_TYPE, $value);
$this->_messages[self::ERROR_INVALID_TYPE] = $message;
return false;
}
if ($this->getOrganizationType() !== null && $this->getOrganizationType() !== $org->getType()) {
$message = $this->_createMessage(self::ERROR_INVALID_ORG_TYPE, $value);
$this->_messages[self::ERROR_INVALID_ORG_TYPE] = $message;
return false;
}
return true;
}
示例12: dispatchLoopStartup
/**
* Route shutdown hook -- Check for router exceptions
*
* @param Zend_Controller_Request_Abstract $request
*/
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
try {
// Avoid error override! :S
if (count($this->getResponse()->getException())) {
return;
}
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()) {
$this->_forceLogout($request, "No session");
return;
}
$sessionId = Zend_Session::getId();
$sessMapper = Application\Model\Mapper\SessionMapper::getInstance();
$session = $sessMapper->findOneById($sessionId);
if (!$session) {
return;
}
if (isset($session['logout'])) {
$this->_forceLogout($request, isset($session['logout']['message']) ? $session['logout']['message'] : "External logout", isset($session['logout']['code']) ? $session['logout']['code'] : PermissionCodes::AUTH_ANOTHER_SESSION_STARTED);
return;
}
} catch (Exception $exc) {
\App::log()->err("MESSAGE BROADCAST: " . $exc->getMessage());
$this->_forceLogout($request, "Unexpected fatal error: " . $exc->getMessage(), 500);
return;
}
}
示例13: rollback
public final function rollback($log = false) {
if ($log) {
App::log('Something went wrong for ' . $this->type . '. Rolling back.');
}
foreach ($this->done as $item) {
Helper::copyr($item['src'], $item['dst'], false);
}
}
示例14: getAction
/**
* Get an specific report by its Id
*/
public function getAction()
{
$params = $this->getRequest()->getQuery();
$params['id'] = $this->getRequest()->getParam('id');
$params['reportType'] = $params['id'];
// Mapping report name (a mistake on spec)
if ($params['id'] === 'charges_detail_monthly') {
$params['id'] = ReportModel::EXPENSE_DETAIL_MONTHLY;
$params['reportType'] = ReportModel::EXPENSE_DETAIL_MONTHLY;
} else {
if ($params['id'] === 'charges_detail_daily') {
$params['id'] = ReportModel::EXPENSE_DETAIL_DAILY;
$params['reportType'] = ReportModel::EXPENSE_DETAIL_DAILY;
}
}
// Check report permissions by type
$dumpReport = new ReportModel();
$dumpReport->setType($params['id']);
try {
$this->_helper->allowed('read', $dumpReport);
} catch (ForbiddenException $ex) {
\App::log()->crit($ex);
if ($dumpReport->getResourceId() == 'report') {
\App::log()->crit("Invalid report type: " . $params['id']);
}
throw new NotAllowedException('List report Operation is not allowed: Customer is not allowed');
}
// Check report params
$this->_reportSrv->validateParams($params['id'], $params);
// Check report organization
if (isset($params['orgId'])) {
try {
$org = OrgService::getInstance()->load($params['orgId']);
} catch (Exception $ex) {
throw new \Application\Exceptions\InvalidArgumentException("Invalid parameter value: " . ReportFilterFields::ORGANIZATION . ". Supported values are customer-xxxxx");
}
if (empty($org)) {
throw new NotFoundException("Resource " . ReportFilterFields::ORGANIZATION . " does not exists");
}
try {
$this->_helper->allowed('read', $org);
} catch (ForbiddenException $ex) {
throw new NotAllowedException('List report Operation is not allowed: Customer is not allowed');
}
}
// Check report exists
if (!$this->_reportSrv->validateReportExists($params)) {
throw new \Application\Exceptions\NotFoundException("Resource report does not exist");
}
// Prepare report download
$downloadToken = new DownloadTokenModel();
$downloadToken->params = $params;
$downloadToken->controller = 'report';
$downloadToken->action = 'get';
$this->_downloadTokenSrv->create($downloadToken);
$this->view->resultURL = $downloadToken->url;
}
示例15: _processErrors
protected function _processErrors()
{
$errors = libxml_get_errors();
foreach ($errors as $err) {
$this->_addError($this->_createError($err));
}
$parseErrors = implode("\n", $this->_errors);
\App::log()->warn("File parser. some errors in XML file: \n" . $parseErrors);
}