Ecodev /
felix
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Ecodev\Felix\Log; |
||
| 6 | |||
| 7 | use Ecodev\Felix\Log\Writer\Db; |
||
|
1 ignored issue
–
show
|
|||
| 8 | use Ecodev\Felix\Log\Writer\Mail; |
||
| 9 | use Interop\Container\ContainerInterface; |
||
| 10 | use Laminas\Log\Logger; |
||
| 11 | use Laminas\Log\Writer\Stream; |
||
| 12 | use Laminas\ServiceManager\Factory\FactoryInterface; |
||
| 13 | |||
| 14 | final class LoggerFactory implements FactoryInterface |
||
| 15 | { |
||
| 16 | private ?Logger $logger = null; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param string $requestedName |
||
| 20 | */ |
||
| 21 | 2 | public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): Logger |
|
| 22 | { |
||
| 23 | 2 | if (!$this->logger) { |
|
| 24 | 2 | $this->logger = new Logger(); |
|
| 25 | |||
| 26 | // Log to file |
||
| 27 | 2 | $fileWriter = new Stream('logs/all.log'); |
|
| 28 | 2 | $this->logger->addWriter($fileWriter); |
|
| 29 | |||
| 30 | // Log to DB |
||
| 31 | /** @var Db $dbWriter */ |
||
| 32 | 2 | $dbWriter = $container->get(Db::class); |
|
| 33 | 2 | $dbWriter->addFilter(Logger::INFO); |
|
| 34 | 2 | $this->logger->addWriter($dbWriter); |
|
| 35 | |||
| 36 | // Maybe log to emails |
||
| 37 | /** @var null|Mail $mailWriter */ |
||
| 38 | 2 | $mailWriter = $container->get(Mail::class); |
|
| 39 | 2 | if ($mailWriter) { |
|
| 40 | 1 | $this->logger->addWriter($mailWriter); |
|
| 41 | } |
||
| 42 | |||
| 43 | // Register to log all kind of PHP errors |
||
| 44 | 2 | Logger::registerErrorHandler($this->logger, true); |
|
| 45 | 2 | Logger::registerFatalErrorShutdownFunction($this->logger); |
|
| 46 | } |
||
| 47 | |||
| 48 | 2 | return $this->logger; |
|
| 49 | } |
||
| 50 | } |
||
| 51 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths