createFormatter() public method

Create one of Monolog formatters by specyfing it name of full class.
public createFormatter ( string $classOrName, mixed[] $args = [] ) : Kraken\Log\Formatter\FormatterInterface
$classOrName string
$args mixed[]
return Kraken\Log\Formatter\FormatterInterface
Example #1
0
 /**
  * @param ConfigInterface $config
  * @param string $level
  * @param int $loggerLevel
  * @return HandlerInterface
  */
 private function createHandler(ConfigInterface $config, $level, $loggerLevel)
 {
     $factory = new LoggerFactory();
     $formatter = $factory->createFormatter('LineFormatter', [$config->get('log.config.messagePattern'), $config->get('log.config.datePattern'), true]);
     $filePermission = $config->get('log.config.filePermission');
     $fileLocking = (bool) $config->get('log.config.fileLocking');
     $filePath = $config->get('log.config.filePattern');
     $loggerHandler = $factory->createHandler('StreamHandler', [$this->filePath($filePath, $level), $loggerLevel, false, $filePermission, $fileLocking]);
     $loggerHandler->setFormatter($formatter);
     return $loggerHandler;
 }
Example #2
0
 /**
  * @param int $loggerLevel
  * @return HandlerInterface
  */
 private function createHandler($loggerLevel)
 {
     $factory = new LoggerFactory();
     $level = $this->getLevelName($loggerLevel);
     $formatter = $factory->createFormatter('LineFormatter', [$this->messagePattern, $this->datePattern, true]);
     $filePermission = 0755;
     $fileLocking = false;
     $filePath = $this->filePattern;
     $loggerHandler = $factory->createHandler('StreamHandler', [$this->filePath($filePath, $level), $loggerLevel, false, $filePermission, $fileLocking]);
     $loggerHandler->setFormatter($formatter);
     return $loggerHandler;
 }