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

Unified Diff: devil/devil/utils/logging_common.py

Issue 2998833002: Revert of [devil] Extract logging common behavior to its own module. (Closed)
Patch Set: Created 3 years, 4 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 | « devil/devil/android/tools/screenshot.py ('k') | devil/devil/utils/run_tests_helper.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: devil/devil/utils/logging_common.py
diff --git a/devil/devil/utils/logging_common.py b/devil/devil/utils/logging_common.py
deleted file mode 100644
index 5aea3c64eeec742256a04f952afaffb98f5f657a..0000000000000000000000000000000000000000
--- a/devil/devil/utils/logging_common.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import logging
-import sys
-import time
-
-
-def AddLoggingArguments(parser):
- parser.add_argument(
- '-v', '--verbose', action='count', default=0,
- help='Log more. Use multiple times for even more logging.')
-
-
-def InitializeLogging(args, handler=None):
- if args.verbose == 0:
- log_level = logging.WARNING
- elif args.verbose == 1:
- log_level = logging.INFO
- else:
- log_level = logging.DEBUG
- logger = logging.getLogger()
- logger.setLevel(log_level)
- if not handler:
- handler = logging.StreamHandler(sys.stdout)
- handler.setFormatter(CustomFormatter())
- logger.addHandler(handler)
-
-
-class CustomFormatter(logging.Formatter):
- """Custom log formatter."""
-
- # override
- def __init__(self, fmt='%(threadName)-4s %(message)s'):
- # 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)
- if 'MainThread' in msg[:19]:
- msg = msg.replace('MainThread', 'Main', 1)
- timediff = time.time() - self._creation_time
- return '%s %8.3fs %s' % (record.levelname[0], timediff, msg)
-
« no previous file with comments | « devil/devil/android/tools/screenshot.py ('k') | devil/devil/utils/run_tests_helper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698