/** * {@inheritdoc} */ public function setFormatter(FormatterInterface $formatter) : HandlerInterface { if ($this->handler instanceof FormattableHandlerInterface) { $this->handler->setFormatter($formatter); } throw new \LogicException('The wrapped handler does not implement ' . FormattableHandlerInterface::class); }
private function addFormatter(HandlerInterface $handler, MonologHandlerOptions $options) { if ($formatterOptions = $options->getFormatter()) { $formatterFactory = new MonologFormatterFactory(); $formatter = $formatterFactory->createFormatter($formatterOptions); $handler->setFormatter($formatter); } }
/** * Sets formatter and processors. * * @param HandlerInterface $handler * @return HandlerInterface */ protected function initHandler(HandlerInterface $handler) { if ($this->formatter != null) { $handler->setFormatter($this->formatter); } foreach ($this->processors as $processor) { $handler->pushProcessor($processor); } return $handler; }
/** * @param HandlerInterface $handler */ public function injectFormatter($handler) { if (empty($this->creationOptions['formatter'])) { return; } $formatter = $this->creationOptions['formatter']; if (is_string($formatter)) { /** @var FormatterInterface $formatter */ $formatter = $this->getServiceLocator()->get("monolog.formatter.{$formatter}"); } $handler->setFormatter($formatter); }
/** * @param Logger $Logger Logger to configure * @param HandlerInterface $AbstractHandler Handler to configure * @param array $config formatter configuration * * @throws FormatterClassMissingException * @throws SectionArgsMissingException */ protected function configureFormatter(Logger $Logger, HandlerInterface $AbstractHandler, array $config) { if (!isset($config[Config::FORMATTER_CLASS])) { throw new FormatterClassMissingException('Formatter class is missing for [' . $Logger->getName() . '] log'); } if (!isset($config[Config::FORMATTER_ARGS])) { throw new SectionArgsMissingException('Section args is missing for formatter [' . $Logger->getName() . '] log'); } $Reflector = new ReflectionClass($config[Config::FORMATTER_CLASS]); /** @var FormatterInterface $AbstractFormatter */ $AbstractFormatter = $Reflector->newInstanceArgs($config[Config::FORMATTER_ARGS]); $AbstractHandler->setFormatter($AbstractFormatter); }
/** * {@inheritdoc} */ public function setFormatter(FormatterInterface $formatter) { $this->handler->setFormatter($formatter); return $this; }
/** * @override * @inheritDoc */ public function setFormatter(FormatterInterface $formatter) { return $this->model->setFormatter($formatter); }