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


PHP Logger::error方法代码示例

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


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

示例1: applyRoles

 /**
  * Apply permissions, restrictions and roles to the given user
  *
  * @param   User    $user
  */
 public function applyRoles(User $user)
 {
     $username = $user->getUsername();
     try {
         $roles = Config::app('roles');
     } catch (NotReadableError $e) {
         Logger::error('Can\'t get permissions and restrictions for user \'%s\'. An exception was thrown:', $username, $e);
         return;
     }
     $userGroups = $user->getGroups();
     $permissions = array();
     $restrictions = array();
     $roleObjs = array();
     foreach ($roles as $roleName => $role) {
         if ($this->match($username, $userGroups, $role)) {
             $permissionsFromRole = StringHelper::trimSplit($role->permissions);
             $permissions = array_merge($permissions, array_diff($permissionsFromRole, $permissions));
             $restrictionsFromRole = $role->toArray();
             unset($restrictionsFromRole['users']);
             unset($restrictionsFromRole['groups']);
             unset($restrictionsFromRole['permissions']);
             foreach ($restrictionsFromRole as $name => $restriction) {
                 if (!isset($restrictions[$name])) {
                     $restrictions[$name] = array();
                 }
                 $restrictions[$name][] = $restriction;
             }
             $roleObj = new Role();
             $roleObjs[] = $roleObj->setName($roleName)->setPermissions($permissionsFromRole)->setRestrictions($restrictionsFromRole);
         }
     }
     $user->setPermissions($permissions);
     $user->setRestrictions($restrictions);
     $user->setRoles($roleObjs);
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:40,代码来源:AdmissionLoader.php

示例2: error

 /**
  * Append the given log entry and fail this inspection with the given error
  *
  * @param   $entry  string|Inspection   A log entry or nested inspection
  *
  * @throws  ProgrammingError            When called multiple times
  *
  * @return  this                        fluent interface
  */
 public function error($entry)
 {
     if (isset($this->error)) {
         throw new ProgrammingError('Inspection object used after error');
     }
     Logger::error($entry);
     $this->log[] = $entry;
     $this->error = $entry;
     return $this;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:19,代码来源:Inspection.php

示例3: errorAction

 /**
  * Display exception
  */
 public function errorAction()
 {
     $error = $this->_getParam('error_handler');
     $exception = $error->exception;
     /** @var \Exception $exception */
     Logger::error($exception);
     Logger::error('Stacktrace: %s', $exception->getTraceAsString());
     switch ($error->type) {
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             $modules = Icinga::app()->getModuleManager();
             $path = ltrim($this->_request->get('PATH_INFO'), '/');
             $path = preg_split('~/~', $path);
             $path = array_shift($path);
             $this->getResponse()->setHttpResponseCode(404);
             $this->view->message = $this->translate('Page not found.');
             if ($this->Auth()->isAuthenticated() && $modules->hasInstalled($path) && !$modules->hasEnabled($path)) {
                 $this->view->message .= ' ' . sprintf($this->translate('Enabling the "%s" module might help!'), $path);
             }
             break;
         default:
             switch (true) {
                 case $exception instanceof HttpMethodNotAllowedException:
                     $this->getResponse()->setHttpResponseCode(405);
                     $this->getResponse()->setHeader('Allow', $exception->getAllowedMethods());
                     break;
                 case $exception instanceof HttpNotFoundException:
                     $this->getResponse()->setHttpResponseCode(404);
                     break;
                 case $exception instanceof MissingParameterException:
                     $this->getResponse()->setHttpResponseCode(400);
                     $this->getResponse()->setHeader('X-Status-Reason', 'Missing parameter ' . $exception->getParameter());
                     break;
                 case $exception instanceof HttpBadRequestException:
                     $this->getResponse()->setHttpResponseCode(400);
                     break;
                 case $exception instanceof SecurityException:
                     $this->getResponse()->setHttpResponseCode(403);
                     break;
                 default:
                     $this->getResponse()->setHttpResponseCode(500);
                     break;
             }
             $this->view->message = $exception->getMessage();
             if ($this->getInvokeArg('displayExceptions')) {
                 $this->view->stackTrace = $exception->getTraceAsString();
             }
             break;
     }
     if ($this->getRequest()->isApiRequest()) {
         $this->getResponse()->json()->setErrorMessage($this->view->message)->sendResponse();
     }
     $this->view->request = $error->request;
 }
开发者ID:JakobGM,项目名称:icingaweb2,代码行数:58,代码来源:ErrorController.php

示例4: parse

 /**
  * Parse the given query text and returns the json as expected by the semantic search box
  *
  * @param  String $text     The query to parse
  * @return array            The result structure to be returned in json format
  */
 private function parse($text, $target)
 {
     try {
         $queryTree = $this->registry->createQueryTreeForFilter($text);
         $registry = $this->moduleRegistry;
         return array('state' => 'success', 'proposals' => $this->registry->getProposalsForQuery($text), 'urlParam' => $registry::getUrlForTarget($target, $queryTree), 'valid' => count($this->registry->getIgnoredQueryParts()) === 0);
     } catch (\Exception $exc) {
         Logger::error($exc);
         $this->getResponse()->setHttpResponseCode(500);
         return array('state' => 'error', 'message' => 'Search service is currently not available');
     }
 }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:18,代码来源:FilterController.php

示例5: setAuthenticated

 public function setAuthenticated(User $user, $persist = true)
 {
     $username = $user->getUsername();
     try {
         $config = Config::app();
     } catch (NotReadableError $e) {
         Logger::error(new IcingaException('Cannot load preferences for user "%s". An exception was thrown: %s', $username, $e));
         $config = new Config();
     }
     if ($config->get('preferences', 'store', 'ini') !== 'none') {
         $preferencesConfig = $config->getSection('preferences');
         try {
             $preferencesStore = PreferencesStore::create($preferencesConfig, $user);
             $preferences = new Preferences($preferencesStore->load());
         } catch (Exception $e) {
             Logger::error(new IcingaException('Cannot load preferences for user "%s". An exception was thrown: %s', $username, $e));
             $preferences = new Preferences();
         }
     } else {
         $preferences = new Preferences();
     }
     $user->setPreferences($preferences);
     $groups = $user->getGroups();
     foreach (Config::app('groups') as $name => $config) {
         try {
             $groupBackend = UserGroupBackend::create($name, $config);
             $groupsFromBackend = $groupBackend->getMemberships($user);
         } catch (Exception $e) {
             Logger::error('Can\'t get group memberships for user \'%s\' from backend \'%s\'. An exception was thrown: %s', $username, $name, $e);
             continue;
         }
         if (empty($groupsFromBackend)) {
             continue;
         }
         $groupsFromBackend = array_values($groupsFromBackend);
         $groups = array_merge($groups, array_combine($groupsFromBackend, $groupsFromBackend));
     }
     $user->setGroups($groups);
     $admissionLoader = new AdmissionLoader();
     list($permissions, $restrictions) = $admissionLoader->getPermissionsAndRestrictions($user);
     $user->setPermissions($permissions);
     $user->setRestrictions($restrictions);
     $this->user = $user;
     if ($persist) {
         $this->persistCurrentUser();
     }
 }
开发者ID:xert,项目名称:icingaweb2,代码行数:47,代码来源:Manager.php

示例6: addMessage

 protected function addMessage($message, $type = 'info')
 {
     if (!in_array($type, array('info', 'error', 'warning', 'success'))) {
         throw new ProgrammingError('"%s" is not a valid notification type', $type);
     }
     if ($this->isCli) {
         $msg = sprintf('[%s] %s', $type, $message);
         switch ($type) {
             case 'info':
             case 'success':
                 Logger::info($msg);
                 break;
             case 'warning':
                 Logger::warn($msg);
                 break;
             case 'error':
                 Logger::error($msg);
                 break;
         }
         return;
     }
     $this->messages[] = (object) array('type' => $type, 'message' => $message);
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:23,代码来源:Notification.php

示例7: setupInternationalization

 /**
  * Set up internationalization using gettext
  *
  * @return $this
  */
 protected final function setupInternationalization()
 {
     if ($this->hasLocales()) {
         Translator::registerDomain(Translator::DEFAULT_DOMAIN, $this->getLocaleDir());
     }
     $locale = $this->detectLocale();
     if ($locale === null) {
         $locale = Translator::DEFAULT_LOCALE;
     }
     try {
         Translator::setupLocale($locale);
     } catch (Exception $error) {
         Logger::error($error);
     }
     return $this;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:21,代码来源:ApplicationBootstrap.php

示例8: javascriptAction

 /**
  * Return a javascript file from the application's or the module's public folder
  */
 public function javascriptAction()
 {
     $module = $this->_getParam('module_name');
     $file = $this->_getParam('file');
     if ($module == 'app') {
         $basedir = Icinga::app()->getApplicationDir('../public/js/icinga/components/');
         $filePath = $basedir . $file;
     } else {
         if (!Icinga::app()->getModuleManager()->hasEnabled($module)) {
             Logger::error('Non-existing frontend component "' . $module . '/' . $file . '" was requested. The module "' . $module . '" does not exist or is not active.');
             echo "/** Module not enabled **/";
             return;
         }
         $basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
         $filePath = $basedir . '/public/js/' . $file;
     }
     if (!file_exists($filePath)) {
         Logger::error('Non-existing frontend component "' . $module . '/' . $file . '" was requested, which would resolve to the the path: ' . $filePath);
         echo '/** Module has no js files **/';
         return;
     }
     $response = $this->getResponse();
     $response->setHeader('Content-Type', 'text/javascript');
     $this->setCacheHeader();
     $response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s', filemtime($filePath)) . ' GMT');
     readfile($filePath);
 }
开发者ID:JakobGM,项目名称:icingaweb2,代码行数:30,代码来源:StaticController.php

示例9: authenticate

 /**
  * {@inheritdoc}
  */
 public function authenticate(User $user, $password = null)
 {
     list($username, $field) = static::getRemoteUserInformation();
     if ($username !== null) {
         $user->setExternalUserInformation($username, $field);
         if ($this->stripUsernameRegexp) {
             $stripped = @preg_replace($this->stripUsernameRegexp, '', $username);
             if ($stripped === false) {
                 Logger::error('Failed to strip external username. The configured regular expression is invalid.');
                 return false;
             }
             $username = $stripped;
         }
         $user->setUsername($username);
         return true;
     }
     return false;
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:21,代码来源:ExternalBackend.php

示例10: __toString

 /**
  * Render the stylesheet
  *
  * @return  string
  */
 public function __toString()
 {
     try {
         return $this->render();
     } catch (Exception $e) {
         Logger::error($e);
         return IcingaException::describe($e);
     }
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:14,代码来源:StyleSheet.php

示例11: loadMemberships

 /**
  * Fetch and return the given user's groups from all user group backends
  *
  * @param   User    $user
  *
  * @return  ArrayDatasource
  */
 protected function loadMemberships(User $user)
 {
     $groups = $alreadySeen = array();
     foreach ($this->loadUserGroupBackends() as $backend) {
         try {
             foreach ($backend->getMemberships($user) as $groupName) {
                 if (array_key_exists($groupName, $alreadySeen)) {
                     continue;
                     // Ignore duplicate memberships
                 }
                 $alreadySeen[$groupName] = null;
                 $groups[] = (object) array('group_name' => $groupName, 'backend' => $backend);
             }
         } catch (Exception $e) {
             Logger::error($e);
             Notification::warning(sprintf($this->translate('Failed to fetch memberships from backend %s. Please check your log'), $backend->getName()));
         }
     }
     return new ArrayDatasource($groups);
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:27,代码来源:UserController.php

示例12: addMessage

 /**
  * Add a notification message
  *
  * @param   string $message
  * @param   string $type
  */
 protected function addMessage($message, $type = self::INFO)
 {
     if ($this->isCli) {
         $msg = sprintf('[%s] %s', $type, $message);
         switch ($type) {
             case self::INFO:
             case self::SUCCESS:
                 Logger::info($msg);
                 break;
             case self::ERROR:
                 Logger::error($msg);
                 break;
             case self::WARNING:
                 Logger::warning($msg);
                 break;
         }
     } else {
         $this->messages[] = (object) array('type' => $type, 'message' => $message);
     }
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:26,代码来源:Notification.php

示例13: send

 /**
  * Send the given command over an appropriate Icinga command transport
  *
  * This will try one configured transport after another until the command has been successfully sent.
  *
  * @param   IcingaCommand   $command    The command to send
  * @param   int|null        $now        Timestamp of the command or null for now
  *
  * @throws  CommandTransportException   If sending the Icinga command failed
  */
 public function send(IcingaCommand $command, $now = null)
 {
     $errors = array();
     foreach (static::getConfig() as $name => $transportConfig) {
         $transport = static::createTransport($transportConfig);
         if ($this->transferPossible($command, $transport)) {
             try {
                 $transport->send($command, $now);
             } catch (CommandTransportException $e) {
                 Logger::error($e);
                 $errors[] = sprintf('%s: %s.', $name, rtrim($e->getMessage(), '.'));
                 continue;
                 // Try the next transport
             }
             return;
             // The command was successfully sent
         }
     }
     if (!empty($errors)) {
         throw new CommandTransportException(implode("\n", $errors));
     }
     throw new CommandTransportException(mt('monitoring', 'Failed to send external Icinga command. No transport has been configured' . ' for this instance. Please contact your Icinga Web administrator.'));
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:33,代码来源:CommandTransport.php

示例14: send

 /**
  * Send the given command over an appropriate Icinga command transport
  *
  * This will try one configured transport after another until the command has been successfully sent.
  *
  * @param   IcingaCommand   $command    The command to send
  * @param   int|null        $now        Timestamp of the command or null for now
  *
  * @throws  CommandTransportException   If sending the Icinga command failed
  */
 public function send(IcingaCommand $command, $now = null)
 {
     $tries = 0;
     foreach (static::getConfig() as $transportConfig) {
         $transport = static::createTransport($transportConfig);
         if ($this->transferPossible($command, $transport)) {
             try {
                 $transport->send($command, $now);
             } catch (CommandTransportException $e) {
                 Logger::error($e);
                 $tries += 1;
                 continue;
                 // Try the next transport
             }
             return;
             // The command was successfully sent
         }
     }
     if ($tries > 0) {
         throw new CommandTransportException(mt('monitoring', 'Failed to send external Icinga command. None of the configured transports' . ' was able to transfer the command. Please see the log for more details.'));
     }
     throw new CommandTransportException(mt('monitoring', 'Failed to send external Icinga command. No transport has been configured' . ' for this instance. Please contact your Icinga Web administrator.'));
 }
开发者ID:trigoesrodrigo,项目名称:icingaweb2,代码行数:33,代码来源:CommandTransport.php

示例15: valid

 /**
  * Check whether the current user backend is valid, i.e. it's enabled, not an external user backend and whether its
  * config is valid
  *
  * @return bool
  */
 public function valid()
 {
     if (!$this->config->valid()) {
         // Stop when there are no more backends to check
         return false;
     }
     $backendConfig = $this->config->current();
     if ((bool) $backendConfig->get('disabled', false)) {
         $this->next();
         return $this->valid();
     }
     $name = $this->key();
     try {
         $backend = UserBackend::create($name, $backendConfig);
     } catch (ConfigurationError $e) {
         Logger::error(new ConfigurationError('Can\'t create authentication backend "%s". An exception was thrown:', $name, $e));
         $this->next();
         return $this->valid();
     }
     if ($this->getSkipExternalBackends() && $backend instanceof ExternalBackend) {
         $this->next();
         return $this->valid();
     }
     $this->currentBackend = $backend;
     return true;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:32,代码来源:AuthChain.php


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