Sort the log file dates in reverse order
We want to show log files in descending order. Change-Id: I6f79d9f5a73afa43efec36c3ca99afcde3fe7813 Closes-Bug: #1311405
This commit is contained in:
parent
6174ea470d
commit
3af5216543
@ -65,7 +65,12 @@ def get_errors(error_re, log_file_pattern, minutes):
|
|||||||
# to the config where one can set it with the desired
|
# to the config where one can set it with the desired
|
||||||
# globbing pattern.
|
# globbing pattern.
|
||||||
log_files = [f for f in glob.glob(log_file_pattern)]
|
log_files = [f for f in glob.glob(log_file_pattern)]
|
||||||
log_files.sort()
|
try:
|
||||||
|
log_files.sort(key=lambda f: os.stat(f).st_mtime, reverse=True)
|
||||||
|
except (IOError, OSError) as exc:
|
||||||
|
logger.error(exc)
|
||||||
|
print(exc)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
now_time = datetime.datetime.now()
|
now_time = datetime.datetime.now()
|
||||||
end_time = now_time - datetime.timedelta(minutes=minutes)
|
end_time = now_time - datetime.timedelta(minutes=minutes)
|
||||||
|
Loading…
Reference in New Issue
Block a user