classes/Controllers/Workers.php
public function tail($worker)
    {
        // Form the path to the file
        $file = Model::logPath(urldecode($worker));
        if (!file_exists($file)) {
            throw new Exception('Log not found: '.$file);
        }
        $size = 1024 * 100; // in bytes to get

        // Read from the end of the file
        clearstatcache();
        $fp = fopen($file, 'r');
        fseek($fp, -$size, SEEK_END);
        $contents = explode("\n", fread($fp, $size));
        fclose($fp);

        // Reverse the contents and return
        $contents = array_reverse($contents);
        if (empty($contents[0])) {
            array_shift($contents);
        }
        die(implode("\n", $contents));
    }
public function tail($worker)
    {
        // Form the path to the file
        $file = Model::logPath(urldecode($worker));
        if (!file_exists($file)) {
            throw new Exception('Log not found: '.$file);
        }
        $size = 1024 * 100; // in bytes to get

        // Read from the end of the file
        clearstatcache();
        $fp = fopen($file, 'r');
        fseek($fp, -$size, SEEK_END);
        $contents = explode("\n", fread($fp, $size));
        fclose($fp);

        // Reverse the contents and return
        $contents = array_reverse($contents);
        if (empty($contents[0])) {
            array_shift($contents);
        }
        die(implode("\n", $contents));
    }
public function tail ( $ worker ) { // Form the path to the file $ file = Model :: logPath ( urldecode ( $ worker ) ) ; if ( ! file_exists ( $ file ) ) { throw new Exception ( 'Log not found: ' . $ file ) ; } $ size = 1024 * 100 ; // in bytes to get // Read from the end of the file clearstatcache ( ) ; $ fp = fopen ( $ file , 'r' ) ; fseek ( $ fp , - $ size , SEEK_END ) ; $ contents = explode ( "\n" , fread ( $ fp , $ size ) ) ; fclose ( $ fp ) ; // Reverse the contents and return $ contents = array_reverse ( $ contents ) ; if ( empty ( $ contents [ 0 ] ) ) { array_shift ( $ contents ) ; } die ( implode ( "\n" , $ contents ) ) ; }
Ajax service that tails the log file for the selected worker

@param $worker
Ajax service that tails the log file for the selected worker