Read A Range Of Lines (LCC.web_file.get_range_lines)
Signature
lines, err = LCC.web_file.get_range_lines(path, start_line?, count?, timeout?)
Parameters
- path
String. File to read. - start_line
Number, optional. Starting line index, default1; positive numbers start at1, negative values count from the end (-1is the last line), and0means after the last line. - count
Number, optional. Number of lines to fetch; default-1for the rest of the file. - timeout
Number, optional. Request timeout in seconds, default60.
Returns
- lines
Table. Array of strings with normalised\n;nilon failure. - err
String ornil. Error description when the call fails.
Notes
Reads a range of lines from the file, useful for paginating large logs.
Positive numbers start at1; negative values count from the end (-1is the last line,-2the second-to-last);0means after the last line.
Returnsnilwhen the selected range has no content.
Example
local lines, err = LCC.web_file.get_range_lines("/logs/task.log", 101, 20)
if lines then
for _, line in ipairs(lines) do
print(line)
end
end