本文整理汇总了PHP中OCP\ILogger::log方法的典型用法代码示例。如果您正苦于以下问题:PHP ILogger::log方法的具体用法?PHP ILogger::log怎么用?PHP ILogger::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\ILogger
的用法示例。
在下文中一共展示了ILogger::log方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logException
/**
* Log exception
*
*/
public function logException(\Exception $ex)
{
$exceptionClass = get_class($ex);
$level = \OCP\Util::FATAL;
if (isset($this->nonFatalExceptions[$exceptionClass])) {
$level = \OCP\Util::DEBUG;
}
$message = $ex->getMessage();
if ($ex instanceof Exception) {
if (empty($message)) {
$response = new Response($ex->getHTTPCode());
$message = $response->getStatusText();
}
$message = "HTTP/1.1 {$ex->getHTTPCode()} {$message}";
}
$exception = ['Message' => $message, 'Code' => $ex->getCode(), 'Trace' => $ex->getTraceAsString(), 'File' => $ex->getFile(), 'Line' => $ex->getLine()];
$this->logger->log($level, 'Exception: ' . json_encode($exception), ['app' => $this->appName]);
}
示例2: getSharedSecret
/**
* create shared secret and return it
*
* @return \OC_OCS_Result
*/
public function getSharedSecret()
{
$url = $this->request->getParam('url');
$token = $this->request->getParam('token');
if ($this->trustedServers->isTrustedServer($url) === false) {
$this->logger->log(\OCP\Util::ERROR, 'remote server not trusted (' . $url . ') while getting shared secret');
return new \OC_OCS_Result(null, HTTP::STATUS_FORBIDDEN);
}
if ($this->isValidToken($url, $token) === false) {
$this->logger->log(\OCP\Util::ERROR, 'remote server (' . $url . ') didn\'t send a valid token (got ' . $token . ') while getting shared secret');
return new \OC_OCS_Result(null, HTTP::STATUS_FORBIDDEN);
}
$sharedSecret = $this->secureRandom->generate(32);
$this->trustedServers->addSharedSecret($url, $sharedSecret);
// reset token after the exchange of the shared secret was successful
$this->dbHandler->addToken($url, '');
return new \OC_OCS_Result(['sharedSecret' => $sharedSecret], Http::STATUS_OK);
}
示例3: log
/**
* @inheritdoc
*/
public function log($level, $message, array $context = array())
{
$this->logger->log($level, $message, array_merge($this->context, $context));
}
示例4: log
private function log($level, $message, $params)
{
$msg = vsprintf($message, $params);
$this->logger->log($level, $msg, ['app' => $this->loggerName]);
}