1 | <?php |
||
7 | class Log |
||
8 | { |
||
9 | const EMERGENCY = 'emergency'; |
||
10 | const ALERT = 'alert'; |
||
11 | const CRITICAL = 'critical'; |
||
12 | const ERROR = 'error'; |
||
13 | const WARNING = 'warning'; |
||
14 | const NOTICE = 'notice'; |
||
15 | const INFO = 'info'; |
||
16 | const DEBUG = 'debug'; |
||
17 | |||
18 | protected $file; |
||
19 | protected $log; |
||
20 | |||
21 | public function __construct( $filename ) |
||
28 | |||
29 | public function __toString() |
||
33 | |||
34 | /** |
||
35 | * Action must be taken immediately. |
||
36 | * Example: Entire website down, database unavailable, etc. This should |
||
37 | * trigger the SMS alerts and wake you up. |
||
38 | * |
||
39 | * @param string $message |
||
40 | * @param array $context |
||
41 | * @return void |
||
42 | */ |
||
43 | public function alert( $message, array $context = [] ) |
||
47 | |||
48 | /** |
||
49 | * @return void |
||
50 | */ |
||
51 | public function clear() |
||
56 | |||
57 | /** |
||
58 | * Critical conditions. |
||
59 | * Example: Application component unavailable, unexpected exception. |
||
60 | * |
||
61 | * @param string $message |
||
62 | * @param array $context |
||
63 | * @return void |
||
64 | */ |
||
65 | public function critical( $message, array $context = [] ) |
||
69 | |||
70 | /** |
||
71 | * Detailed debug information. |
||
72 | * |
||
73 | * @param string $message |
||
74 | * @param array $context |
||
75 | * @return void |
||
76 | */ |
||
77 | public function debug( $message, array $context = [] ) |
||
81 | |||
82 | /** |
||
83 | * System is unusable. |
||
84 | * |
||
85 | * @param string $message |
||
86 | * @param array $context |
||
87 | * @return void |
||
88 | */ |
||
89 | public function emergency( $message, array $context = [] ) |
||
93 | |||
94 | /** |
||
95 | * Runtime errors that do not require immediate action but should typically |
||
96 | * be logged and monitored. |
||
97 | * |
||
98 | * @param string $message |
||
99 | * @param array $context |
||
100 | * @return void |
||
101 | */ |
||
102 | public function error( $message, array $context = [] ) |
||
106 | |||
107 | /** |
||
108 | * Interesting events. |
||
109 | * Example: User logs in, SQL logs. |
||
110 | * |
||
111 | * @param string $message |
||
112 | * @param array $context |
||
113 | * @return void |
||
114 | */ |
||
115 | public function info( $message, array $context = [] ) |
||
119 | |||
120 | /** |
||
121 | * Normal but significant events. |
||
122 | * |
||
123 | * @param string $message |
||
124 | * @param array $context |
||
125 | * @return void |
||
126 | */ |
||
127 | public function notice( $message, array $context = [] ) |
||
131 | |||
132 | /** |
||
133 | * Exceptional occurrences that are not errors. |
||
134 | * Example: Use of deprecated APIs, poor use of an API, undesirable things |
||
135 | * that are not necessarily wrong. |
||
136 | * |
||
137 | * @param string $message |
||
138 | * @param array $context |
||
139 | * @return void |
||
140 | */ |
||
141 | public function warning( $message, array $context = [] ) |
||
145 | |||
146 | /** |
||
147 | * @param string $message |
||
148 | * @param array $context |
||
149 | * @return array|string |
||
150 | */ |
||
151 | protected function interpolate( $message, array $context = [] ) |
||
171 | |||
172 | /** |
||
173 | * @param mixed $level |
||
174 | * @param string $message |
||
175 | * @param array $context |
||
176 | * @return void |
||
177 | */ |
||
178 | protected function log( $level, $message, array $context = [] ) |
||
190 | } |
||
191 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.