Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Unified Diff: build/android/pylib/utils/run_tests_helper.py

Issue 13601030: [android] Improve logging output. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: old Python compatability Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/cmd_helper.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/utils/run_tests_helper.py
diff --git a/build/android/pylib/utils/run_tests_helper.py b/build/android/pylib/utils/run_tests_helper.py
index 15e5d5381bcc9b6d9a3e97dcbed40191556a9904..b5730b6893aa544b2096772fc95180fd992b3d7a 100644
--- a/build/android/pylib/utils/run_tests_helper.py
+++ b/build/android/pylib/utils/run_tests_helper.py
@@ -6,6 +6,26 @@
import logging
import os
+import time
+
+
+class CustomFormatter(logging.Formatter):
+ """Custom log formatter."""
+
+ #override
+ def __init__(self, fmt=''):
+ # Can't use super() because in older Python versions logging.Formatter does
+ # not inherit from object.
+ logging.Formatter.__init__(self, fmt=fmt)
+ self._creation_time = time.time()
+
+ #override
+ def format(self, record):
+ # Can't use super() because in older Python versions logging.Formatter does
+ # not inherit from object.
+ msg = logging.Formatter.format(self, record)
+ timediff = str(int(time.time() - self._creation_time))
+ return '%s %ss %s' % (record.levelname[0], timediff.rjust(4), msg)
def GetExpectations(file_name):
@@ -23,4 +43,8 @@ def SetLogLevel(verbose_count):
log_level = logging.INFO
elif verbose_count >= 2:
log_level = logging.DEBUG
- logging.getLogger().setLevel(log_level)
+ logger = logging.getLogger()
+ logger.setLevel(log_level)
+ custom_handler = logging.StreamHandler()
+ custom_handler.setFormatter(CustomFormatter())
+ logging.getLogger().addHandler(custom_handler)
« no previous file with comments | « build/android/pylib/cmd_helper.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698