1 | <?php |
||
19 | class Logger |
||
20 | { |
||
21 | /** |
||
22 | * @var resource |
||
23 | */ |
||
24 | private $handle; |
||
25 | |||
26 | /** |
||
27 | * @var resource |
||
28 | */ |
||
29 | private $warnHandle; |
||
30 | |||
31 | /** |
||
32 | * @var resource |
||
33 | */ |
||
34 | private $errorHandle; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $storageDir; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private static $remoteIp; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | private static $script; |
||
50 | |||
51 | /** |
||
52 | * @param string $remoteIp |
||
53 | * @param string $script |
||
54 | */ |
||
55 | public static function setup($remoteIp, $script) |
||
60 | |||
61 | /** |
||
62 | * @param string $localeStorageDir Use better the local TMP dir or dir with mod 777. |
||
63 | */ |
||
64 | public function __construct($localeStorageDir) |
||
68 | |||
69 | /** |
||
70 | * @throws \RuntimeException If something went wrong on creating the log dir and file. |
||
71 | */ |
||
72 | public function init() |
||
94 | |||
95 | /** |
||
96 | * @param string $msg |
||
97 | * |
||
98 | * @return Logger |
||
99 | */ |
||
100 | public function debug($msg) |
||
108 | |||
109 | /** |
||
110 | * @param string $msg |
||
111 | * |
||
112 | * @return Logger |
||
113 | */ |
||
114 | public function warn($msg) |
||
122 | |||
123 | /** |
||
124 | * @param string $msg |
||
125 | * |
||
126 | * @return Logger |
||
127 | */ |
||
128 | public function error($msg) |
||
134 | |||
135 | /** |
||
136 | * @param string $msg |
||
137 | * |
||
138 | * @return Logger |
||
139 | */ |
||
140 | public function info($msg) |
||
148 | |||
149 | /** |
||
150 | * @param string $msg |
||
151 | * @param string $severity |
||
152 | */ |
||
153 | protected function write($msg, $severity = 'DEBUG') |
||
166 | |||
167 | public function __destruct() |
||
182 | |||
183 | /** |
||
184 | * Formats the error message in representable manner. |
||
185 | * |
||
186 | * @param string $message |
||
187 | * @param string $severity |
||
188 | * |
||
189 | * @return string |
||
190 | */ |
||
191 | private function format($message, $severity) |
||
216 | |||
217 | /** |
||
218 | * @param string $varname |
||
219 | * |
||
220 | * @return bool |
||
221 | */ |
||
222 | protected function iniGetBool($varname) |
||
238 | } |
||
239 |