Conditions | 5 |
Paths | 8 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
30 | public function log() |
||
31 | { |
||
32 | $logger = app()->path()->appLog().''.DIRECTORY_SEPARATOR.''.date('Y').''.DIRECTORY_SEPARATOR.''.date('m').''.DIRECTORY_SEPARATOR.''.date('d').'-access.log'; |
||
33 | |||
34 | $tailCommand = 'tail -n 1 -f '.escapeshellarg($logger).''; |
||
35 | |||
36 | while (@ ob_end_flush()); // end all output buffers if any |
||
37 | |||
38 | $proc = popen($tailCommand, 'r'); |
||
39 | while (!feof($proc)) |
||
40 | { |
||
41 | $result = fread($proc, 4096); |
||
42 | if(preg_match('@\{(.*)\}@',$result,$output)){ |
||
43 | $outputArray = json_decode($output[0],1); |
||
44 | |||
45 | if(app()->has('track.log')){ |
||
46 | |||
47 | $track = app()->get('track.log'); |
||
48 | echo $track($outputArray); |
||
49 | } |
||
50 | } |
||
51 | @ flush(); |
||
52 | } |
||
55 | } |