Skip to content

Commit

Permalink
Laravel allow to change stream direction
Browse files Browse the repository at this point in the history
  • Loading branch information
GDXbsv committed Aug 8, 2022
1 parent 724a6b5 commit 3e337a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
],
```

Expand Down
4 changes: 3 additions & 1 deletion src/Laravel/LaravelLoggerCreating.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
Expand Down

0 comments on commit 3e337a9

Please sign in to comment.