Passed
Push — master ( ec5386...e56f88 )
by Andrey
53s queued 14s
created

LoggingBootloader::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 15
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 26
rs 9.7666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Application\Bootloader;
6
7
use Monolog\Logger;
0 ignored issues
show
Bug introduced by
The type Monolog\Logger was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Spiral\Boot\Bootloader\Bootloader;
0 ignored issues
show
Bug introduced by
The type Spiral\Boot\Bootloader\Bootloader was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Spiral\Config\ConfiguratorInterface;
0 ignored issues
show
Bug introduced by
The type Spiral\Config\ConfiguratorInterface was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Spiral\Http\Middleware\ErrorHandlerMiddleware;
0 ignored issues
show
Bug introduced by
The type Spiral\Http\Middleware\ErrorHandlerMiddleware was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Spiral\Monolog\Bootloader\MonologBootloader;
0 ignored issues
show
Bug introduced by
The type Spiral\Monolog\Bootloader\MonologBootloader was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Spiral\Monolog\Config\MonologConfig;
0 ignored issues
show
Bug introduced by
The type Spiral\Monolog\Config\MonologConfig was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
/**
15
 * The bootloader is responsible for configuring the application specific loggers.
16
 *
17
 * @link https://spiral.dev/docs/basics-logging
18
 */
19
final class LoggingBootloader extends Bootloader
20
{
21
    public function __construct(
22
        private readonly ConfiguratorInterface $config,
23
    ) {
24
    }
25
26
    public function init(MonologBootloader $monolog): void
27
    {
28
        // HTTP level errors
29
        $monolog->addHandler(
30
            channel: ErrorHandlerMiddleware::class,
31
            handler: $monolog->logRotate(
32
                directory('runtime') . 'logs/http.log',
0 ignored issues
show
Bug introduced by
The function directory was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
                /** @scrutinizer ignore-call */ 
33
                directory('runtime') . 'logs/http.log',
Loading history...
33
            ),
34
        );
35
36
        // app level errors
37
        $monolog->addHandler(
38
            channel: MonologConfig::DEFAULT_CHANNEL,
39
            handler: $monolog->logRotate(
40
                filename: directory('runtime') . 'logs/error.log',
41
                level: Logger::ERROR,
42
                maxFiles: 25,
43
                bubble: false,
44
            ),
45
        );
46
47
        // debug and info messages via global LoggerInterface
48
        $monolog->addHandler(
49
            channel: MonologConfig::DEFAULT_CHANNEL,
50
            handler: $monolog->logRotate(
51
                filename: directory('runtime') . 'logs/debug.log',
52
            ),
53
        );
54
    }
55
}
56