|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Jean Silva <me@jeancsil> |
|
4
|
|
|
* @license MIT |
|
5
|
|
|
*/ |
|
6
|
|
|
namespace Jeancsil\FlightSpy\Log; |
|
7
|
|
|
|
|
8
|
|
|
use Monolog\Logger; |
|
9
|
|
|
|
|
10
|
|
|
class ArrayLogger extends Logger |
|
11
|
|
|
{ |
|
12
|
|
|
const COLOR_NONE = "[0m"; |
|
|
|
|
|
|
13
|
|
|
const COLOR_RED = "[31m"; |
|
|
|
|
|
|
14
|
|
|
const COLOR_GREEN = "[32m"; |
|
|
|
|
|
|
15
|
|
|
const COLOR_YELLOW = "[33m"; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
public function debug($items, array $context = []) |
|
18
|
|
|
{ |
|
19
|
|
|
foreach ((array) $items as $item) { |
|
20
|
|
|
parent::debug($this->format($item), $context); |
|
21
|
|
|
} |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function info($items, array $context = []) |
|
25
|
|
|
{ |
|
26
|
|
|
foreach ((array) $items as $item) { |
|
27
|
|
|
parent::info($this->format($item), $context); |
|
28
|
|
|
} |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function notice($items, array $context = []) |
|
32
|
|
|
{ |
|
33
|
|
|
foreach ((array) $items as $item) { |
|
34
|
|
|
parent::notice($this->format($item), $context); |
|
35
|
|
|
} |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function warn($items, array $context = []) |
|
39
|
|
|
{ |
|
40
|
|
|
foreach ((array) $items as $item) { |
|
41
|
|
|
parent::warn($this->format($item), $context); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function error($items, array $context = []) |
|
46
|
|
|
{ |
|
47
|
|
|
foreach ((array) $items as $item) { |
|
48
|
|
|
parent::error($this->format($item, self::COLOR_RED), $context); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function critical($items, array $context = []) |
|
53
|
|
|
{ |
|
54
|
|
|
foreach ((array) $items as $item) { |
|
55
|
|
|
parent::critical($this->format($item, self::COLOR_YELLOW), $context); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function alert($items, array $context = []) |
|
60
|
|
|
{ |
|
61
|
|
|
foreach ((array) $items as $item) { |
|
62
|
|
|
parent::alert($this->format($item), $context); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function emergency($items, array $context = []) |
|
67
|
|
|
{ |
|
68
|
|
|
foreach ((array) $items as $item) { |
|
69
|
|
|
parent::emergency($this->format($item), $context); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
private function format($message, $color = self::COLOR_GREEN) |
|
74
|
|
|
{ |
|
75
|
|
|
return chr(27) . "$color$message" . chr(27) . self::COLOR_NONE; |
|
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.