本文整理汇总了PHP中Psr\Log\LoggerInterface::warning方法的典型用法代码示例。如果您正苦于以下问题:PHP LoggerInterface::warning方法的具体用法?PHP LoggerInterface::warning怎么用?PHP LoggerInterface::warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Log\LoggerInterface
的用法示例。
在下文中一共展示了LoggerInterface::warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postModule
public function postModule(PostModuleEvent $event)
{
$pageModuleWrapper = $event->getModuleWrapper();
$queryCount = $event->getExtra('module_profiler.query_count');
$time = microtime(true) - $event->getExtra('module_profiler.time');
$userTime = Helper::getCpuTime('u') - $event->getExtra('module_profiler.user_time');
$systemTime = Helper::getCpuTime('s') - $event->getExtra('module_profiler.system_time');
$memoryUsage = memory_get_usage(true) - $event->getExtra('module_profiler.memory_usage');
$sqlQueries = $queryCount !== null ? Propel::getQueryCount() - $queryCount : null;
if ($userTime + $systemTime > $this->cpuLimit || $time > $this->timeLimit) {
$this->logger->warning('Module generation time exceeded limit');
}
if ($memoryUsage > $this->memoryLimit) {
$this->logger->warning('Module memory usage exceeded limit');
}
if ($sqlQueries > $this->sqlLimit) {
$this->logger->warning('Module sql query count exceeded limit');
}
// add module debug info
$this->moduleDebugInfo[] = array($pageModuleWrapper->getName(), $pageModuleWrapper->getClassName(), $pageModuleWrapper->getTemplate(), $pageModuleWrapper->getTarget(), (bool) $event->getExtra('module_cacher.cached'), round($time * 1000.0), round(($userTime + $systemTime) * 1000.0), Helper::humanReadableBytes($memoryUsage), Helper::humanReadableBytes(memory_get_peak_usage(true)), $sqlQueries !== null ? $sqlQueries : 'n/a');
// Remove values to prevent caching
$extras = $event->getExtras();
unset($extras['module_profiler.time']);
unset($extras['module_profiler.query_count']);
unset($extras['module_profiler.user_time']);
unset($extras['module_profiler.system_time']);
unset($extras['module_profiler.memory_usage']);
$event->setExtras($extras);
}
示例2: log
/**
* {@inheritdoc}
*/
public function log($message, $level)
{
$message .= ' ' . $this->request->getRequestUri();
if ($this->logLevel >= $level) {
switch ($level) {
case self::EMERGENCY:
$this->logger->emergency($message);
break;
case self::ALERT:
$this->logger->alert($message);
break;
case self::CRITICAL:
$this->logger->critical($message);
break;
case self::ERROR:
$this->logger->error($message);
break;
case self::WARNING:
$this->logger->warning($message);
break;
case self::NOTICE:
$this->logger->notice($message);
break;
case self::INFO:
$this->logger->info($message);
break;
default:
$this->logger->debug($message);
}
}
}
示例3: logState
/**
* Log the state of the analysis.
*
* @param \StyleCI\StyleCI\Models\Analysis
*
* @return void
*/
protected function logState(Analysis $analysis)
{
switch ($analysis->status) {
case Analysis::PENDING:
$this->logger->debug('Analysis has been queued.', $this->getContext($analysis));
break;
case Analysis::RUNNING:
$this->logger->debug('Analysis has started running.', $this->getContext($analysis));
break;
case Analysis::PASSED:
case Analysis::CS_ISSUES:
case Analysis::SYNTAX_ISSUES:
case Analysis::BOTH_ISSUES:
$this->logger->debug('Analysis has completed successfully.', $this->getContext($analysis));
break;
case Analysis::CONFIG_ISSUES:
$this->logger->notice('Analysis has failed due to misconfiguration.', $this->getContext($analysis));
break;
case Analysis::ACCESS_ISSUES:
$this->logger->warning('Analysis has failed due to git access issues.', $this->getContext($analysis));
break;
case Analysis::TIMEOUT:
$this->logger->error('Analysis has failed due to a platform timeout.', $this->getContext($analysis));
break;
default:
$this->logger->error('Analysis has failed due to an internal error.', $this->getContext($analysis));
}
}
示例4: handleException
/**
* @param Exception $e the Exception that was thrown
* @param string $command the command that was being executed
* @param array $args the arguments of the command
* @throws \Plista\Core\Redis\Exception
* @return bool
*/
private function handleException(Exception $e, $command, $args)
{
$excBrief = "{$e->getCode()}: {$e->getMessage()} ({$e->getFile()}:{$e->getLine()}) Stacktrace:\n" . $e->getTraceAsString();
// $excHash = md5($excBrief);
// $curTime = Registry::getSystem()->getTime()->current();
//
// $this->excLog[$excHash]['count']++;
// $this->excLog[$excHash]['time'] = $curTime;
// log the exception
$this->log->warning("Caught Redis exception: {$excBrief}");
if ($this->exceptionHandler) {
// notify the handler and get the strategy
$context = ExceptionContext::fromFunctionAndArguments($command, $args);
$strategy = $this->exceptionHandler->handleException($e, $context);
} else {
// use the default strategy
$strategy = $this->defaultHandlerStrategy;
}
// default is to discard the exception
if (!$strategy) {
$strategy = ExceptionStrategy::DISCARD();
}
// let's see what the handler wants us to do
if ($strategy->equals(ExceptionStrategy::RETHROW)) {
throw $e;
}
// this case is used by the FailoverWrapper
if ($strategy->equals(ExceptionStrategy::RETURN_VALUE)) {
return $strategy->returnValue;
}
// return false to signal failure. maybe interpreted by some callers as a valid value (which it
// is in some cases), but that's not for us to worry about.
return false;
}
示例5: getController
/** {@inheritdoc} */
public function getController(RequestInterface $request)
{
if (!($controller = $request->getAttributes()->get('_controller'))) {
$this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing.');
return false;
}
if (is_array($controller)) {
return $controller;
}
if (is_object($controller)) {
if (method_exists($controller, '__invoke')) {
return $controller;
}
throw new \InvalidArgumentException(sprintf('Controller "%s" for method "%s" is not callable.', get_class($controller), $request->getMethod()));
}
if (false === strpos($controller, ':')) {
if (method_exists($controller, '__invoke')) {
return $this->instantiateController($controller);
} elseif (function_exists($controller)) {
return $controller;
}
}
$callable = $this->createController($controller);
if (!is_callable($callable)) {
throw new \InvalidArgumentException(sprintf('The controller for method "%s" is not callable. %s', $request->getMethod(), $this->getControllerError($callable)));
}
return $callable;
}
示例6: doHandle
/**
* traitement réel du paiement
*
* @param Ecedi\Donate\OgoneBundle\Ogone\Response $response
* @return Payment the payment instance
*/
protected function doHandle(Response $response)
{
//initialize payment
$payment = new Payment();
$payment->setAutorisation($response->getAcceptance())->setTransaction($response->getPayId())->setResponseCode($response->getStatus())->setResponse($response);
$normalizer = $this->container->get('donate_ogone.status_normalizer');
$payment->setStatus($normalizer->normalize($response->getStatus()));
try {
//validate response
$this->validate($response);
$this->logger->debug('Payment Status : ' . $payment->getStatus());
} catch (UnauthorizedPostSaleException $e) {
$this->logger->warning('Incorrectly signed post-sale received');
$payment->setStatus(Payment::STATUS_INVALID);
}
//add payment to intent
try {
$intentId = $this->getIntentId($response);
$this->logger->debug('found intent id ' . $intentId);
} catch (CannotDetermineOrderIdException $e) {
$this->logger->warning('CannotDetermineOrderIdException');
$intentId = false;
//TODO le payment p-e ok, mais il est orphelin
}
$this->intentManager->attachPayment($intentId, $payment);
return $payment;
}
示例7: getController
/**
* {@inheritdoc}
*
* This method looks for a '_controller' request attribute that represents
* the controller name (a string like ClassName::MethodName).
*
* @api
*/
public function getController(Request $request)
{
if (!($controller = $request->attributes->get('_controller'))) {
if (null !== $this->logger) {
$this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing');
}
return false;
}
if (is_array($controller)) {
return $controller;
}
if (is_object($controller)) {
if (method_exists($controller, '__invoke')) {
return $controller;
}
throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', get_class($controller), $request->getPathInfo()));
}
if (false === strpos($controller, ':')) {
if (method_exists($controller, '__invoke')) {
return $this->app->make($controller);
} elseif (function_exists($controller)) {
return $controller;
}
}
$callable = $this->createController($controller);
if (!is_callable($callable)) {
throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', $controller, $request->getPathInfo()));
}
return $callable;
}
示例8: handleErrorException
/**
* @param \ErrorException $exception
*
* @return bool
*/
protected function handleErrorException(\ErrorException $exception)
{
switch ($exception->getSeverity()) {
case E_ERROR:
case E_RECOVERABLE_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_PARSE:
$this->logger->error($this->buildLogMessage($exception));
break;
case E_WARNING:
case E_USER_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
$this->logger->warning($this->buildLogMessage($exception));
break;
case E_NOTICE:
case E_USER_NOTICE:
$this->logger->notice($this->buildLogMessage($exception));
break;
case E_STRICT:
case E_DEPRECATED:
case E_USER_DEPRECATED:
$this->logger->info($this->buildLogMessage($exception));
break;
}
return true;
}
示例9: login
/**
* @param string $username
* @param string $password
* @param null|string $requiredGroupRole
* @return bool
*/
public function login($username, $password, $requiredGroupRole = null)
{
if (empty($username) || empty($password)) {
return false;
}
$user = $this->userProvider->loadUserByUsername($username);
if (!$user) {
$this->logger->warning(sprintf('Login failed for "%s". User not found', $username));
sleep(1);
return false;
}
if (null !== $requiredGroupRole) {
$groupRoles = $user->getGroupRoles();
if (!in_array($requiredGroupRole, $groupRoles)) {
$this->logger->warning(sprintf('Login failed for "%s". Not in requested group role "%s" vs "%s"', $username, $requiredGroupRole, implode(',', $groupRoles)));
sleep(1);
return false;
}
}
$encoder = $this->encoderFactory->getEncoder($user);
if (!$encoder->isPasswordValid($user->getPassword(), $password, null)) {
$this->logger->warning(sprintf('Login failed for "%s". Password missmatch ', $username));
sleep(1);
return false;
}
$this->manualLogin($user);
return true;
}
示例10: getController
/**
* Returns the Controller instance associated with a Request.
*
* This method looks for a '_controller' request attribute that represents
* the controller name (a string like ClassName::MethodName).
*
* @param Request $request A Request instance
*
* @return mixed|Boolean A PHP callable representing the Controller,
* or false if this resolver is not able to determine the controller
*
* @throws \InvalidArgumentException|\LogicException If the controller can't be found
*
* @api
*/
public function getController(\Symfony\Component\HttpFoundation\Request $request)
{
if (!($controller = $request->attributes->get('_controller'))) {
if (null !== $this->logger) {
$this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing');
}
return false;
}
if (is_array($controller) || is_object($controller) && method_exists($controller, '__invoke')) {
return $controller;
}
if (false === strpos($controller, ':')) {
if (method_exists($controller, '__invoke')) {
return new $controller();
} elseif (function_exists($controller)) {
return $controller;
}
}
list($controller, $method) = $this->createController($controller);
$this->parameters = array();
if ($suffix = $request->attributes->get('_suffix')) {
$parameters_temp = explode('/', $suffix);
$parameters_temp = array_filter($parameters_temp, function ($el) {
return $el !== '';
});
foreach ($parameters_temp as $p) {
$this->parameters[] = $p;
}
}
if ($method === '*') {
if (count($this->parameters) > 0) {
$method = array_shift($this->parameters);
} elseif ($default_suffix = $request->attributes->get('_default_suffix')) {
$method = $default_suffix;
} else {
$method = 'index';
}
}
/** @var $controller ControllerInterface */
$controller->setContext($this->context);
$controller->setRequest($request);
if (method_exists($controller, 'before')) {
$controller->before($method);
}
if (method_exists($controller, 'security')) {
if (!$controller->security()) {
return array($controller, 'redirectToLogin');
}
}
if (method_exists($controller, 'router')) {
list($controller, $method, $this->parameters) = $controller->router($method, $this->parameters);
} else {
$method = 'action_' . $method;
}
if (!method_exists($controller, $method)) {
throw new NotFoundHttpException();
//throw new \InvalidArgumentException(sprintf('Method "%s::%s" does not exist.', get_class($controller), $method));
}
return array($controller, $method);
}
示例11: getFieldValue
/**
* Returns parsed field value.
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
* @param string $field
* @param string $language
*
* @return array
*/
public function getFieldValue(Content $content, $field, $language)
{
$fieldObj = $content->getField($field, $language);
$contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
$imageFieldIdentifier = $this->getImageFieldIdentifier($content->id, $language);
$relatedContentId = $this->getRelation($content, $fieldObj->fieldDefIdentifier, $language);
$mapping = $this->relationMapper->getMapping($contentType->identifier, $field);
try {
if ($relatedContentId && $mapping) {
$relatedContent = $this->contentService->loadContent($relatedContentId);
if ($relatedContent && $relatedContent->versionInfo->contentInfo->published) {
$relatedContentType = $this->contentTypeService->loadContentType($relatedContent->contentInfo->contentTypeId);
if ($relatedContentType->identifier != $mapping['content']) {
throw new InvalidRelationException(sprintf("Invalid relation: field '%s:%s' (object: %s, field: %s) has improper relation to object '%s' (object: %s) but '%s:%s' expected.", $contentType->identifier, $field, $content->id, $fieldObj->id, $relatedContentType->identifier, $relatedContentId, $mapping['content'], $mapping['field']));
}
$relatedField = $content->getField($mapping['field'], $language);
$value = $relatedField ? $this->getParsedFieldValue($relatedField, $relatedContent, $language, $imageFieldIdentifier) : '';
} else {
$value = '';
}
} else {
$value = $fieldObj ? $this->getParsedFieldValue($fieldObj, $content, $language, $imageFieldIdentifier) : '';
}
} catch (InvalidRelationException $exception) {
$this->logger->warning($exception->getMessage());
$value = '';
}
return array('key' => $field, 'value' => $value);
}
示例12: setDeployment
/**
* Performs the request to make the deployment
*
* @param string $description
* @param bool $change
* @param bool $user
*
* @return bool|string
*/
public function setDeployment($description, $change = false, $user = false)
{
$apiUrl = $this->config->getNewRelicApiUrl();
if (empty($apiUrl)) {
$this->logger->notice('New Relic API URL is blank, using fallback URL');
$apiUrl = self::API_URL;
}
/** @var \Magento\Framework\HTTP\ZendClient $client */
$client = $this->clientFactory->create();
$client->setUri($apiUrl);
$client->setMethod(ZendClient::POST);
$client->setHeaders(['x-api-key' => $this->config->getNewRelicApiKey()]);
$params = ['deployment[app_name]' => $this->config->getNewRelicAppName(), 'deployment[application_id]' => $this->config->getNewRelicAppId(), 'deployment[description]' => $description, 'deployment[changelog]' => $change, 'deployment[user]' => $user];
$client->setParameterPost($params);
try {
$response = $client->request();
} catch (\Zend_Http_Client_Exception $e) {
$this->logger->critical($e);
return false;
}
if ($response->getStatus() < 200 || $response->getStatus() > 210) {
$this->logger->warning('Deployment marker request did not send a 200 status code.');
return false;
}
return $response->getBody();
}
示例13: triggerWebtreesAdminTasks
public function triggerWebtreesAdminTasks()
{
$settings = new Settings();
$this->logger = \Piwik\Container\StaticContainer::get('Psr\\Log\\LoggerInterface');
$this->logger->info('Webtrees Admin Task triggered');
$rooturl = $settings->getSetting('webtreesRootUrl');
if (!$rooturl || strlen($rooturl->getValue()) === 0) {
return;
}
$token = $settings->getSetting('webtreesToken');
if (!$token || strlen($token->getValue()) === 0) {
return;
}
$taskname = $settings->getSetting('webtreesTaskName');
if (!$taskname || strlen($taskname->getValue()) === 0) {
return;
}
$url = sprintf('%1$s/module.php?mod=perso_admintasks&mod_action=trigger&force=%2$s&task=%3$s', $rooturl->getValue(), $token->getValue(), $taskname->getValue());
$this->logger->info('webtrees url : {url}', array('url' => $url));
try {
\Piwik\Http::sendHttpRequest($url, Webtrees::SOCKET_TIMEOUT);
} catch (Exception $e) {
$this->logger->warning('an error occured', array('exception' => $e));
}
}
示例14: convert
/**
* Converts internal links (ezcontent:// and ezlocation://) to URLs.
*
* @param \DOMDocument $document
*
* @return \DOMDocument
*/
public function convert(DOMDocument $document)
{
$document = clone $document;
$xpath = new DOMXPath($document);
$xpath->registerNamespace("docbook", "http://docbook.org/ns/docbook");
$linkAttributeExpression = "starts-with( @xlink:href, 'ezlocation://' ) or starts-with( @xlink:href, 'ezcontent://' )";
$xpathExpression = "//docbook:link[{$linkAttributeExpression}]|//docbook:ezlink";
/** @var \DOMElement $link */
foreach ($xpath->query($xpathExpression) as $link) {
// Set resolved href to number character as a default if it can't be resolved
$hrefResolved = "#";
$href = $link->getAttribute("xlink:href");
$location = null;
preg_match("~^(.+://)?([^#]*)?(#.*|\\s*)?\$~", $href, $matches);
list(, $scheme, $id, $fragment) = $matches;
if ($scheme === "ezcontent://") {
try {
$contentInfo = $this->contentService->loadContentInfo($id);
$location = $this->locationService->loadLocation($contentInfo->mainLocationId);
$hrefResolved = $this->urlAliasRouter->generate($location) . $fragment;
} catch (APINotFoundException $e) {
if ($this->logger) {
$this->logger->warning("While generating links for richtext, could not locate " . "Content object with ID " . $id);
}
} catch (APIUnauthorizedException $e) {
if ($this->logger) {
$this->logger->notice("While generating links for richtext, unauthorized to load " . "Content object with ID " . $id);
}
}
} else {
if ($scheme === "ezlocation://") {
try {
$location = $this->locationService->loadLocation($id);
$hrefResolved = $this->urlAliasRouter->generate($location) . $fragment;
} catch (APINotFoundException $e) {
if ($this->logger) {
$this->logger->warning("While generating links for richtext, could not locate " . "Location with ID " . $id);
}
} catch (APIUnauthorizedException $e) {
if ($this->logger) {
$this->logger->notice("While generating links for richtext, unauthorized to load " . "Location with ID " . $id);
}
}
} else {
$hrefResolved = $href;
}
}
$hrefAttributeName = "xlink:href";
// For embeds set the resolved href to the separate attribute
// Original href needs to be preserved in order to generate link parameters
// This will need to change with introduction of UrlService and removal of URL link
// resolving in external storage
if ($link->localName === "ezlink") {
$hrefAttributeName = "href_resolved";
}
$link->setAttribute($hrefAttributeName, $hrefResolved);
}
return $document;
}
示例15: convertToEz
/**
* Converts a locale in POSIX format to eZ Publish internal format.
* Returns null if conversion cannot be made.
*
* @param string $posixLocale
*
* @return string|null
*/
public function convertToEz($posixLocale)
{
if (!isset($this->reverseConversionMap[$posixLocale])) {
$this->logger->warning("Could not convert locale '{$posixLocale}' to eZ Publish format. Please check your locale configuration in ezpublish.yml");
return;
}
return $this->reverseConversionMap[$posixLocale];
}