update
This commit is contained in:
@@ -328,19 +328,33 @@ function perform_check!(st::State)
|
|||||||
# println(5)
|
# println(5)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function limitTextFileLines(LogFilePath::String; maxlines::Integer=100)
|
function limitTextFileLines(LogFilePath::String; maxlines::Integer=100)
|
||||||
log = readlines(LogFilePath)
|
log = readlines(LogFilePath)
|
||||||
if length(log) < (maxlines - 1)
|
total_lines = length(log)
|
||||||
|
if total_lines < maxlines
|
||||||
return nothing
|
return nothing
|
||||||
end
|
end
|
||||||
|
exceeding_row = total_lines - maxlines # can be 0 or more
|
||||||
|
reduced_lines = log[exceeding_row+2:end]
|
||||||
reducedLog = ""
|
reducedLog = ""
|
||||||
for i in log[end-(maxlines-1):end]
|
for i in reduced_lines
|
||||||
reducedLog = reducedLog * i * "\n"
|
reducedLog = reducedLog * i * "\n"
|
||||||
end
|
end
|
||||||
write(LogFilePath, reducedLog)
|
write(LogFilePath, reducedLog)
|
||||||
end
|
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
|
# Main loop: runs indefinitely every CHECK_INTERVAL_SECS
|
||||||
function main_loop()
|
function main_loop()
|
||||||
# Ensure log file exists
|
# Ensure log file exists
|
||||||
|
|||||||
Reference in New Issue
Block a user