This commit is contained in:
2026-04-18 20:11:49 +07:00
parent 77c06befda
commit 9a0cb6d272

View File

@@ -328,19 +328,33 @@ function perform_check!(st::State)
# println(5)
end
function limitTextFileLines(LogFilePath::String; maxlines::Integer=100)
log = readlines(LogFilePath)
if length(log) < (maxlines - 1)
total_lines = length(log)
if total_lines < maxlines
return nothing
end
exceeding_row = total_lines - maxlines # can be 0 or more
reduced_lines = log[exceeding_row+2:end]
reducedLog = ""
for i in log[end-(maxlines-1):end]
for i in reduced_lines
reducedLog = reducedLog * i * "\n"
end
write(LogFilePath, reducedLog)
end
# function limitTextFileLines(LogFilePath::String; maxlines::Integer=100)
# log = readlines(LogFilePath)
# if length(log) < (maxlines - 1)
# return nothing
# end
# reducedLog = ""
# for i in log[end-(maxlines-1):end]
# reducedLog = reducedLog * i * "\n"
# end
# write(LogFilePath, reducedLog)
# end
# Main loop: runs indefinitely every CHECK_INTERVAL_SECS
function main_loop()
# Ensure log file exists