|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; |
| 6 | +use Symfony\Config\MonologConfig; |
| 7 | + |
| 8 | +return static function (ContainerConfigurator $containerConfigurator, MonologConfig $monologConfig): void { |
| 9 | + $monologConfig->channels(['deprecation']); |
| 10 | + |
| 11 | + if ('dev' === $containerConfigurator->env()) { |
| 12 | + $monologConfig->handler('main') |
| 13 | + ->type('stream') |
| 14 | + ->path('%kernel.logs_dir%/%kernel.environment%.log') |
| 15 | + ->level('debug') |
| 16 | + ->channels() |
| 17 | + ->elements(['!event']); |
| 18 | + $monologConfig->handler('console') |
| 19 | + ->type('console') |
| 20 | + ->processPsr3Messages(false) |
| 21 | + ->channels() |
| 22 | + ->elements(['!event', '!doctrine', '!console']); |
| 23 | + } |
| 24 | + |
| 25 | + if ('test' === $containerConfigurator->env()) { |
| 26 | + $monologConfig->handler('main') |
| 27 | + ->type('fingers_crossed') |
| 28 | + ->actionLevel('error') |
| 29 | + ->handler('nested') |
| 30 | + ->excludedHttpCode(404) |
| 31 | + ->excludedHttpCode(405) |
| 32 | + ->channels() |
| 33 | + ->elements(['!event']); |
| 34 | + $monologConfig->handler('nested') |
| 35 | + ->type('stream') |
| 36 | + ->path('%kernel.logs_dir%/%kernel.environment%.log') |
| 37 | + ->level('debug'); |
| 38 | + } |
| 39 | + |
| 40 | + if ('prod' === $containerConfigurator->env()) { |
| 41 | + $monologConfig->handler('main') |
| 42 | + ->type('fingers_crossed') |
| 43 | + ->actionLevel('error') |
| 44 | + ->handler('nested') |
| 45 | + ->excludedHttpCode(404) |
| 46 | + ->excludedHttpCode(405) |
| 47 | + // How many messages should be saved? Prevent memory leaks |
| 48 | + ->bufferSize(50); |
| 49 | + $monologConfig->handler('nested') |
| 50 | + ->type('stream') |
| 51 | + ->path('php://stderr') |
| 52 | + ->level('debug') |
| 53 | + ->formatter('monolog.formatter.json'); |
| 54 | + $monologConfig->handler('console') |
| 55 | + ->type('console') |
| 56 | + ->processPsr3Messages(false) |
| 57 | + ->channels() |
| 58 | + ->elements(['!event', '!doctrine']); |
| 59 | + $monologConfig->handler('deprecation') |
| 60 | + ->type('stream') |
| 61 | + ->path('php://stderr') |
| 62 | + ->formatter('monolog.formatter.json') |
| 63 | + ->channels() |
| 64 | + ->elements(['deprecation']); |
| 65 | + } |
| 66 | +}; |
0 commit comments