Example #1
0
function get_lines_from_file($file_, $nb_lines, $allowed_types)
{
    // Add false to the array to get mismatch log lines
    // $allowed_types[]= false;
    $lines = array();
    $obj = new FileTailer($file_);
    $qty = 0;
    while ($obj->hasLines()) {
        $ret = $obj->tail(1);
        $line = $ret[0];
        $type = parse_linux($line);
        if (!in_array($type, $allowed_types)) {
            continue;
        }
        array_unshift($lines, '<span class="' . $type . '">' . trim($line) . '</span>');
        $qty++;
        if ($qty >= $nb_lines) {
            break;
        }
    }
    return $lines;
}