Skip to content

Commit

Permalink
Allow to set minimal log level
Browse files Browse the repository at this point in the history
  • Loading branch information
GDXbsv committed Jul 28, 2022
1 parent 4576f85 commit cd4a10e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ add in `config/logging.php` in `channels` section:
'app_name' => 'ServiceName',
'channel' => 'app'(security/reauest/order),
'processors' => [new Monolog\Processor\ProcessorInterface()], //OPTIONAL
'level' => Monolog\Logger::INFO, //OPTIONAL
]
'security' => [
'driver' => 'custom',
'via' => new Gotphoto\Logging\Laravel\LaravelLoggerCreating,
'app_name' => 'ServiceName',
'channel' => 'security',
'processors' => [new Monolog\Processor\ProcessorInterface()], //OPTIONAL
'level' => Monolog\Logger::INFO, //OPTIONAL
],
```

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Integrate a common way for log handling.",
"type": "library",
"require": {
"php": "^7|^8",
"php": "^7.3|^8",
"monolog/monolog": "^2.7|^3.1",
"newrelic/monolog-enricher": "^2.0"
},
Expand Down
4 changes: 3 additions & 1 deletion src/Laravel/LaravelLoggerCreating.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function __invoke(array $config)
$channel = $config['channel'];
/** @var \Monolog\Processor\ProcessorInterface[] $processors */
$processors = $config['processors'] ?? [];
/** @var int $level */
$level = $config['level'] ?? Logger::DEBUG;

$log = new Logger($channel);
$log->pushProcessor(new Processor());
Expand All @@ -33,7 +35,7 @@ public function __invoke(array $config)
$log->pushProcessor($processor);
}

$streamHandler = new StreamHandler('php://stderr');
$streamHandler = new StreamHandler('php://stderr', $level);

$handler = $streamHandler;
$env = App::environment();
Expand Down

0 comments on commit cd4a10e

Please sign in to comment.