本文整理匯總了PHP中Psr\Log\LoggerInterface::addInfo方法的典型用法代碼示例。如果您正苦於以下問題:PHP LoggerInterface::addInfo方法的具體用法?PHP LoggerInterface::addInfo怎麽用?PHP LoggerInterface::addInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Psr\Log\LoggerInterface
的用法示例。
在下文中一共展示了LoggerInterface::addInfo方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: process
/**
* Returns the the path to the processed image
*
* @param string $sFilter
* @param string $sOptions
* @param string $sFile
*
* @return string
*
* @throws \Exception
*/
public function process($sFilter, $sOptions, $sFile)
{
$this->oLogger->addInfo("filter=" . $sFilter . "; file=" . $sFile);
// check if filter exists
$sFilterClass = "\\Pids\\Filter\\" . ucfirst(strtolower($sFilter));
if (!class_exists($sFilterClass)) {
throw new \Exception("Filter " . $sFilterClass . " does not exist.");
}
$oFilter = new $sFilterClass();
// check if image exists else use default image
if (!file_exists('data' . DIRECTORY_SEPARATOR . $sFile)) {
$sFile = $this->aConfig["image"]["default"];
$this->oLogger->addDebug("using default image");
}
$this->sSourceImage = 'data' . DIRECTORY_SEPARATOR . $sFile;
// check if cache is up to date
$this->sCacheImage = $this->getCachePath($sFilter, $sOptions, $sFile);
if (file_exists($this->sCacheImage) && filemtime($this->sSourceImage) < filemtime($this->sCacheImage)) {
$this->oLogger->addDebug("cache file was up to date");
return $this->sCacheImage;
}
//TODO separate method
$rFinfo = finfo_open(FILEINFO_MIME_TYPE);
$sMime = finfo_file($rFinfo, $this->sSourceImage, FILEINFO_MIME_TYPE);
switch ($sMime) {
case 'image/jpeg':
case 'image/jpg':
$rImage = imagecreatefromjpeg($this->sSourceImage);
break;
case 'image/png':
$rImage = imagecreatefrompng($this->sSourceImage);
break;
default:
throw new \Exception('Unsupported mime type ' . $sMime);
}
// create cache file
$rImage = $oFilter->apply($rImage, $sOptions, $this->aConfig["filters"][strtolower($sFilter)]);
if ($this->aConfig["image"]["watermark"]) {
$rImage = $oFilter->addWatermark($rImage);
}
//TODO separate method
switch ($sMime) {
case 'image/jpeg':
case 'image/jpg':
imagejpeg($rImage, $this->sCacheImage, $this->aConfig["image"]["quality"]);
break;
case 'image/png':
imagepng($rImage, $this->sCacheImage, ceil($this->aConfig["image"]["quality"] / 10));
break;
}
$this->oLogger->addDebug("cache file created:" . $this->sCacheImage);
return $this->sCacheImage;
}
示例2: execute
/**
* Execute
*
* @return Wrapper
*/
public function execute()
{
$base = $this->generateCommand();
foreach ($this->document as $name => $doc) {
/* @var $doc Document */
if ($doc->getPassword()) {
$command = sprintf('%s --password=%s', $base, $doc->getPassword());
} else {
$command = $base;
}
$command = sprintf('%s %s', $command, escapeshellarg($doc->getPath()));
if ($this->logger) {
$this->logger->addInfo(sprintf('Tika command: "%s"', $command));
}
$process = new Process($command);
$process->run();
if (!$process->isSuccessful()) {
throw new \InvalidArgumentException($process->getErrorOutput());
}
$content = $process->getIncrementalOutput();
$doc->setRawContent($content);
if ($this->config->getMetadataOnly()) {
$this->loadMetadata($doc, $content);
} else {
if (in_array($this->config->getOutputFormat(), array('xml', 'html'))) {
$this->loadDocument($doc, $content);
} else {
$doc->setContent($content);
}
}
}
return $this;
}