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

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/system/log_utils.py

Issue 2948043002: webkitpy: Add time output to the start of logging messages. (Closed)
Patch Set: Changing the right log handler. Created 3 years, 6 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 | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/system/log_utils_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Tools/Scripts/webkitpy/common/system/log_utils.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/system/log_utils.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/system/log_utils.py
index a862bd5783ff7916fb61226101861a3386e29b50..1c0c9bf1e049c26b5f6ec5a308d239cae47e34b8 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/common/system/log_utils.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/system/log_utils.py
@@ -28,11 +28,12 @@ import sys
_log = logging.getLogger(__name__)
-def _default_handlers(stream, logging_level):
+def _default_handlers(stream, logging_level, no_time):
"""Return a list of the default logging handlers to use.
Args:
stream: See the configure_logging() docstring.
+ no_time: See the configure_logging() docstring.
"""
# Create the filter.
def should_log(record):
@@ -46,10 +47,15 @@ def _default_handlers(stream, logging_level):
# Create the handler.
handler = logging.StreamHandler(stream)
+ if no_time:
+ prefix = ''
+ else:
+ prefix = '%(asctime)s - '
+
if logging_level == logging.DEBUG:
- formatter = logging.Formatter('%(name)s: [%(levelname)s] %(message)s')
+ formatter = logging.Formatter(prefix + '%(name)s: [%(levelname)s] %(message)s')
else:
- formatter = logging.Formatter('%(message)s')
+ formatter = logging.Formatter(prefix + '%(message)s')
handler.setFormatter(formatter)
handler.addFilter(logging_filter)
@@ -58,7 +64,7 @@ def _default_handlers(stream, logging_level):
def configure_logging(logging_level=None, logger=None, stream=None,
- handlers=None):
+ handlers=None, no_time=False):
qyearsley 2017/06/21 16:42:26 It might be a bit clearer to rename this to avoid
mithro 2017/06/23 00:37:57 Done.
"""Configure logging for standard purposes.
Returns:
@@ -96,7 +102,7 @@ def configure_logging(logging_level=None, logger=None, stream=None,
if stream is None:
stream = sys.stderr
if handlers is None:
- handlers = _default_handlers(stream, logging_level)
+ handlers = _default_handlers(stream, logging_level, no_time)
logger.setLevel(logging_level)
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/system/log_utils_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698