| Conditions | 5 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function watch($logPath, $stringToEcho) |
||
| 11 | { |
||
| 12 | $this->checkLogPermissions($logPath); |
||
| 13 | $size = 0; |
||
| 14 | while (true) { |
||
| 15 | clearstatcache(); |
||
| 16 | $currentSize = filesize($logPath); |
||
| 17 | if ($size === $currentSize) { |
||
| 18 | usleep(500); |
||
| 19 | continue; |
||
| 20 | } |
||
| 21 | $fh = fopen($logPath, 'r'); |
||
| 22 | fseek($fh, $size); |
||
| 23 | while ($line = fgets($fh)) { |
||
| 24 | if (strpos($line, $stringToEcho) !== false) { |
||
| 25 | echo $line; |
||
| 26 | } |
||
| 27 | } |
||
| 28 | fclose($fh); |
||
| 29 | $size = $currentSize; |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 45 |