$count = isset($_GET['count']) ? $_GET['count'] : (isset($files[$file_id]['max']) ? $files[$file_id]['max'] : LOGS_MAX); $timeout = isset($_GET['timeout']) ? $_GET['timeout'] : MAX_SEARCH_LOG_TIME; $regex = $files[$file_id]['format']['regex']; $match = $files[$file_id]['format']['match']; $types = $files[$file_id]['format']['types']; $multiline = isset($files[$file_id]['format']['multiline']) ? $files[$file_id]['format']['multiline'] : ''; $exclude = isset($files[$file_id]['format']['exclude']) ? $files[$file_id]['format']['exclude'] : array(); $title = isset($files[$file_id]['format']['export_title']) ? $files[$file_id]['format']['export_title'] : ''; $file_path = $files[$file_id]['path']; $start_offset = 0; $start_from = SEEK_END; $load_more = false; $old_lastline = ''; $data_to_parse = filesize($file_path); $full = true; $logs = LogParser::getNewLines($regex, $match, $types, $tz, $count, $exclude, $file_path, $start_offset, $start_from, $load_more, $old_lastline, $multiline, $search, $data_to_parse, $full, $timeout); /* |-------------------------------------------------------------------------- | Error while getting logs |-------------------------------------------------------------------------- | */ if (!is_array($logs)) { http500(); } /* |-------------------------------------------------------------------------- | Return |-------------------------------------------------------------------------- | */
// Log file has been rotated, read all. It is not possible on apache because server is restarted gracefully but perhaps user has done something... $data_to_parse = $new_file_size; $full = true; $return['notice'] = '<strong>' . $now . '</strong> : ' . sprintf(__('Log file has been rotated (previous size was %s and new one is %s)'), human_filesize($old_file_size), human_filesize($new_file_size)); } if ($old_file_size === 0) { $full = true; } } /* |-------------------------------------------------------------------------- | Get logs |-------------------------------------------------------------------------- | */ $logs = LogParser::getNewLines($regex, $match, $types, $tz, $max, $exclude, $file_path, $start_offset, $start_from, $load_more, $old_lastline, $multiline, $search, $data_to_parse, $full, MAX_SEARCH_LOG_TIME); /* |-------------------------------------------------------------------------- | Error while getting logs |-------------------------------------------------------------------------- | */ if (!is_array($logs)) { switch ($logs) { case '1': $return['error'] = sprintf(__('File <code>%s</code> for file ID <code>%s</code> does not exist anymore...'), $file_path, $file_id); break; default: $return['error'] = sprintf(__('Unknown error %s'), $logs); break; }