From 113a712c7557143328282dbe97b62f152b0f523a Mon Sep 17 00:00:00 2001 From: Juerg Gutknecht Date: Tue, 28 Apr 2015 11:19:20 +0200 Subject: [PATCH] Loading processors from service manager, if available --- src/EnliteMonolog/Service/MonologServiceFactory.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/EnliteMonolog/Service/MonologServiceFactory.php b/src/EnliteMonolog/Service/MonologServiceFactory.php index 9cd293b..b36f594 100644 --- a/src/EnliteMonolog/Service/MonologServiceFactory.php +++ b/src/EnliteMonolog/Service/MonologServiceFactory.php @@ -7,6 +7,7 @@ use Closure; +use Exception; use Monolog\Logger; use Monolog\Formatter\FormatterInterface; use RuntimeException; @@ -151,6 +152,16 @@ public function createProcessor(ServiceLocatorInterface $serviceLocator, $proces } if (is_string($processor)) { + try { + $instance = $serviceLocator->get($processor); + } catch (Exception $ex) { + $instance = null; + } + + if ($instance && is_callable($instance)) { + return $instance; + } + $processor = new $processor(); if (is_callable($processor)) {