本文整理汇总了PHP中Psr\Log\LoggerInterface::crit方法的典型用法代码示例。如果您正苦于以下问题:PHP LoggerInterface::crit方法的具体用法?PHP LoggerInterface::crit怎么用?PHP LoggerInterface::crit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Log\LoggerInterface
的用法示例。
在下文中一共展示了LoggerInterface::crit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logException
/**
* Logs exceptions.
*
* @param \Exception $originalException Original exception that called the listener
* @param \Exception $generatedException Generated exception
* @param string|null $message Message to log
*/
private function logException(\Exception $originalException, \Exception $generatedException, $message = null)
{
if (!$message) {
$message = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($generatedException), $generatedException->getMessage());
}
if (null !== $this->logger) {
if (!$originalException instanceof HttpExceptionInterface || $originalException->getStatusCode() >= 500) {
$this->logger->crit($message, array('exception' => $originalException));
} else {
$this->logger->err($message, array('exception' => $originalException));
}
} else {
error_log($message);
}
}
示例2: critInternal
/**
* Adds a log record at the `CRITICAL` level.
*
* This method allows for compatibility with common interfaces.
*
* @param string $message log message
* @param array $placeholders placeholders for replacement
* @return bool Whether the record has been processed
*/
protected function critInternal($message, array $placeholders = [])
{
return $this->logger->crit(StringHelper::replace($message, $placeholders, false), $placeholders);
}