Completed
Push — master ( 30a8ff...83681b )
by Taosikai
12:10
created

Logger::getFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Spike library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Spike\Logger;
7
8
use Monolog\Logger as Monologer;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class Logger extends Monologer
12
{
13
    /**
14
     * The log file
15
     * @var string
16
     */
17
    protected $file;
18
19
    /**
20
     * The log level
21
     * @var int|string
22
     */
23
    protected $level;
24
25
    /**
26
     * @var OutputInterface
27
     */
28
    protected $output;
29
30
    public function __construct($level, $file, OutputInterface $output)
31
    {
32
        $this->level = $level;
33
        $this->file = $file;;
34
        $this->output = $output;
35
        parent::__construct('', $this->createHandlers());
36
    }
37
38
    protected function createHandlers()
39
    {
40
        return [
41
            new FileHandler($this->file, $this->level),
42
            new ConsoleHandler($this->output, $this->level),
43
        ];
44
    }
45
46
    /**
47
     * Gets the log level
48
     * @return int|string
49
     */
50
    public function getLevel()
51
    {
52
        return $this->level;
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getFile()
59
    {
60
        return $this->file;
61
    }
62
63
    /**
64
     * @return OutputInterface
65
     */
66
    public function getOutput()
67
    {
68
        return $this->output;
69
    }
70
}