1 | <?php |
||
2 | /** |
||
3 | * Automation tool mixed with code generator for easier continuous development |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/hidev |
||
6 | * @package hidev |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2015-2018, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hidev\components; |
||
12 | |||
13 | use yii\log\Logger; |
||
14 | |||
15 | /** |
||
16 | * Log dispatcher component. |
||
17 | */ |
||
18 | class Log extends \yii\log\Dispatcher |
||
19 | { |
||
20 | protected $_level = Logger::LEVEL_WARNING; |
||
21 | |||
22 | protected $levels = [ |
||
23 | 'error' => Logger::LEVEL_ERROR, |
||
24 | 'warning' => Logger::LEVEL_WARNING, |
||
25 | 'info' => Logger::LEVEL_INFO, |
||
26 | ]; |
||
27 | |||
28 | protected $names; |
||
29 | |||
30 | public function setLevel($value) |
||
31 | { |
||
32 | if (isset($this->levels[$value])) { |
||
33 | $this->_level = $this->levels[$value]; |
||
34 | |||
35 | return; |
||
36 | } |
||
37 | if (in_array($value, $this->levels, false)) { |
||
38 | $this->_level = $value; |
||
39 | } |
||
40 | |||
41 | Yii::warning("wrong log level: $value"); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
42 | } |
||
43 | |||
44 | public function getLevel() |
||
45 | { |
||
46 | return $this->_level; |
||
47 | } |
||
48 | |||
49 | public function getLevelName($level = null) |
||
50 | { |
||
51 | if ($level === null) { |
||
52 | $level = $this->_level; |
||
53 | } |
||
54 | |||
55 | return isset($this->levelNames[$level]) ? $this->levelNames[$level] : null; |
||
0 ignored issues
–
show
The property
levelNames does not exist on hidev\components\Log . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
56 | } |
||
57 | |||
58 | public function getLevelNames() |
||
59 | { |
||
60 | if ($this->names === null) { |
||
61 | $this->names = array_flip($this->levels); |
||
62 | } |
||
63 | |||
64 | return $this->names; |
||
65 | } |
||
66 | } |
||
67 |