Logger::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the slince/spike package.
5
 *
6
 * (c) Slince <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Spike\Common\Logger;
13
14
use Monolog\Logger as Monologer;
15
use React\EventLoop\LoopInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
class Logger extends Monologer
19
{
20
    /**
21
     * @var LoopInterface
22
     */
23
    protected $eventLoop;
24
25
    /**
26
     * The log file.
27
     *
28
     * @var string
29
     */
30
    protected $file;
31
32
    /**
33
     * The log level.
34
     *
35
     * @var int|string
36
     */
37
    protected $level;
38
39
    /**
40
     * @var OutputInterface
41
     */
42
    protected $output;
43
44
    public function __construct(LoopInterface $loop, $level, $file, OutputInterface $output)
45
    {
46
        $this->eventLoop = $loop;
47
        $this->level = $level;
48
        $this->file = $file;
49
        $this->output = $output;
50
        parent::__construct('', $this->createHandlers());
51
    }
52
53
    protected function createHandlers()
54
    {
55
        return [
56
            new FileHandler($this->eventLoop, $this->file, $this->level),
57
            new ConsoleHandler($this->eventLoop, $this->output, $this->level),
58
        ];
59
    }
60
}