From 3af5216543a8a6e769822c4175cf840e572b628c Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 24 Apr 2014 11:02:54 -0400 Subject: [PATCH] Sort the log file dates in reverse order We want to show log files in descending order. Change-Id: I6f79d9f5a73afa43efec36c3ca99afcde3fe7813 Closes-Bug: #1311405 --- bin/swift-drive-audit | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/swift-drive-audit b/bin/swift-drive-audit index a283daad26..3d9227ba06 100755 --- a/bin/swift-drive-audit +++ b/bin/swift-drive-audit @@ -65,7 +65,12 @@ def get_errors(error_re, log_file_pattern, minutes): # to the config where one can set it with the desired # globbing 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() end_time = now_time - datetime.timedelta(minutes=minutes)