From 7ba0c22133da7ca99d1ec1459630de01f95130c1 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 16 Jan 2018 11:51:18 -0600 Subject: [PATCH] support aggregate drivers --- src/Illuminate/Log/LogManager.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Log/LogManager.php b/src/Illuminate/Log/LogManager.php index 4186015d9d41..3629e1c2c629 100644 --- a/src/Illuminate/Log/LogManager.php +++ b/src/Illuminate/Log/LogManager.php @@ -96,8 +96,8 @@ public function driver($driver = null) protected function get($name) { try { - return $this->stores[$name] ?? with($this->resolve($name), function ($monolog) use ($name) { - return $this->tap($name, new Logger($monolog, $this->app['events'])); + return $this->stores[$name] ?? with($this->resolve($name), function ($logger) use ($name) { + return $this->tap($name, new Logger($logger, $this->app['events'])); }); } catch (Throwable $e) { return tap($this->createEmergencyLogger(), function ($logger) use ($e) { @@ -200,6 +200,21 @@ protected function createCustomDriver(array $config) return $this->app->make($config['via'])->__invoke($config); } + /** + * Create a aggregate log driver instance. + * + * @param array $config + * @return \Psr\Log\LoggerInterface + */ + protected function createAggregateDriver(array $config) + { + $handlers = collect($config['channels'])->flatMap(function ($channel) { + return $this->channel($channel)->getHandlers(); + })->all(); + + return new Monolog($this->parseChannel($config), $handlers); + } + /** * Create an instance of the single file log driver. *