From 3e337a96a2e1441468bdca4cedad9e57768a1a4a Mon Sep 17 00:00:00 2001 From: "sergei.baikin" Date: Mon, 8 Aug 2022 15:15:23 +0200 Subject: [PATCH] Laravel allow to change stream direction --- README.md | 2 ++ src/Laravel/LaravelLoggerCreating.php | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 23e5068..a6a7612 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ add in `config/logging.php` in `channels` section: 'channel' => 'app'(security/reauest/order), 'processors' => [new Monolog\Processor\ProcessorInterface()], //OPTIONAL 'level' => Monolog\Logger::INFO, //OPTIONAL + 'stream_to' => 'php://stderr', //OPTIONAL ] 'security' => [ 'driver' => 'custom', @@ -72,6 +73,7 @@ add in `config/logging.php` in `channels` section: 'channel' => 'security', 'processors' => [new Monolog\Processor\ProcessorInterface()], //OPTIONAL 'level' => Monolog\Logger::INFO, //OPTIONAL + 'stream_to' => 'php://stderr', //OPTIONAL ], ``` diff --git a/src/Laravel/LaravelLoggerCreating.php b/src/Laravel/LaravelLoggerCreating.php index 2760b12..94037d7 100644 --- a/src/Laravel/LaravelLoggerCreating.php +++ b/src/Laravel/LaravelLoggerCreating.php @@ -28,6 +28,8 @@ public function __invoke(array $config) $processors = $config['processors'] ?? []; /** @var int $level */ $level = $config['level'] ?? Logger::DEBUG; + /** @var string $stream */ + $stream = $config['stream_to'] ?? 'php://stderr'; $log = new Logger($channel); $log->pushProcessor(new Processor()); @@ -37,7 +39,7 @@ public function __invoke(array $config) $log->pushProcessor($processor); } - $streamHandler = new StreamHandler('php://stderr', $level); + $streamHandler = new StreamHandler($stream, $level); $handler = $streamHandler; $env = App::environment();