src/Shell/CakeResqueShell.php
public function tail()
    {
        $logs = [];
        $i = 1;
        $workersArgs = $this->ResqueStatus->getWorkers();

        foreach ($workersArgs as $workerArgs) {
            if ($workerArgs['log'] != '') {
                $logs[] = $workerArgs['log'];
            }
            if ($workerArgs['Log']['handler'] == 'RotatingFile') {
                $fileInfo = pathinfo($workerArgs['Log']['target']);
                $pattern = $fileInfo['dirname'] . DS . $fileInfo['filename'] . '-*' . (!empty($fileInfo['extension']) ? '.' . $fileInfo['extension'] : '');

                $logs = array_merge($logs, glob($pattern));
            }
        }

        $logs = array_values(array_unique($logs));

        $this->out('<info>' . __d('cake_resque', 'Tailing log file') . '</info>');
        if (empty($logs)) {
            $this->out('    <error>' . __d('cake_resque', 'No log file to tail') . '</error>', 2);

            return false;
        } elseif (count($logs) == 1) {
            $index = 1;
        } else {
            foreach ($logs as $log) {
                $this->out(sprintf('    [%3d] - %s', $i++, $log));
            }

            $index = $this->in(__d('cake_resque', 'Choose a log file to tail') . ':', range(1, $i - 1));
        }

        $this->out('<warning>' . __d('cake_resque', 'Tailing {0}', $logs[ $index - 1 ]) . '</warning>');
        $this->_tail($logs[ $index - 1 ]);
    }
public function tail()
    {
        $logs = [];
        $i = 1;
        $workersArgs = $this->ResqueStatus->getWorkers();

        foreach ($workersArgs as $workerArgs) {
            if ($workerArgs['log'] != '') {
                $logs[] = $workerArgs['log'];
            }
            if ($workerArgs['Log']['handler'] == 'RotatingFile') {
                $fileInfo = pathinfo($workerArgs['Log']['target']);
                $pattern = $fileInfo['dirname'] . DS . $fileInfo['filename'] . '-*' . (!empty($fileInfo['extension']) ? '.' . $fileInfo['extension'] : '');

                $logs = array_merge($logs, glob($pattern));
            }
        }

        $logs = array_values(array_unique($logs));

        $this->out('<info>' . __d('cake_resque', 'Tailing log file') . '</info>');
        if (empty($logs)) {
            $this->out('    <error>' . __d('cake_resque', 'No log file to tail') . '</error>', 2);

            return false;
        } elseif (count($logs) == 1) {
            $index = 1;
        } else {
            foreach ($logs as $log) {
                $this->out(sprintf('    [%3d] - %s', $i++, $log));
            }

            $index = $this->in(__d('cake_resque', 'Choose a log file to tail') . ':', range(1, $i - 1));
        }

        $this->out('<warning>' . __d('cake_resque', 'Tailing {0}', $logs[ $index - 1 ]) . '</warning>');
        $this->_tail($logs[ $index - 1 ]);
    }
public function tail ( ) { $ logs = [ ] ; $ i = 1 ; $ workersArgs = $ this -> ResqueStatus -> getWorkers ( ) ; foreach ( $ workersArgs as $ workerArgs ) { if ( $ workerArgs [ 'log' ] != '' ) { $ logs [ ] = $ workerArgs [ 'log' ] ; } if ( $ workerArgs [ 'Log' ] [ 'handler' ] == 'RotatingFile' ) { $ fileInfo = pathinfo ( $ workerArgs [ 'Log' ] [ 'target' ] ) ; $ pattern = $ fileInfo [ 'dirname' ] . DS . $ fileInfo [ 'filename' ] . '-*' . ( ! empty ( $ fileInfo [ 'extension' ] ) ? '.' . $ fileInfo [ 'extension' ] : '' ) ; $ logs = array_merge ( $ logs , glob ( $ pattern ) ) ; } } $ logs = array_values ( array_unique ( $ logs ) ) ; $ this -> out ( '<info>' . __d ( 'cake_resque' , 'Tailing log file' ) . '</info>' ) ; if ( empty ( $ logs ) ) { $ this -> out ( '    <error>' . __d ( 'cake_resque' , 'No log file to tail' ) . '</error>' , 2 ) ; return false ; } elseif ( count ( $ logs ) == 1 ) { $ index = 1 ; } else { foreach ( $ logs as $ log ) { $ this -> out ( sprintf ( '    [%3d] - %s' , $ i ++ , $ log ) ) ; } $ index = $ this -> in ( __d ( 'cake_resque' , 'Choose a log file to tail' ) . ':' , range ( 1 , $ i - 1 ) ) ; } $ this -> out ( '<warning>' . __d ( 'cake_resque' , 'Tailing {0}' , $ logs [ $ index - 1 ] ) . '</warning>' ) ; $ this -> _tail ( $ logs [ $ index - 1 ] ) ; }
Monitor the content of a log file onscreen.

Ask user to choose from a list of available log file, if there's more than one,
and display all new content on screen.
This will only search for log file created by resque, and the RotatingFile created by log-handler.

Note: The workers status is conveniently stored by ResqueStatus.

@return bool False if no logs to tail.
@see ResqueStatus\ResqueStatus::getWorkers()
Monitor the content of a log file onscreen .