OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 """Common library methods. |
| 5 |
| 6 These methods can be used by both the host and the client code. |
| 7 """ |
| 8 import argparse |
| 9 import logging |
| 10 import socket |
| 11 import sys |
| 12 import xmlrpclib |
| 13 import SimpleXMLRPCServer |
| 14 |
| 15 LOGGING_FORMAT = ('%(asctime)s %(filename)s:%(lineno)s %(levelname)s] ' |
| 16 '%(message)s') |
| 17 LOGGING_DATE_FORMAT = '%H:%M:%S' |
| 18 MY_IP = socket.gethostbyname(socket.gethostname()) |
| 19 |
| 20 |
| 21 def InitLogging(): |
| 22 """Initialize the logging module.""" |
| 23 parser = argparse.ArgumentParser() |
| 24 parser.add_argument('--verbose', action='store_true') |
| 25 args, _ = parser.parse_known_args() |
| 26 level = logging.DEBUG if args.verbose else logging.INFO |
| 27 logging.basicConfig(format=LOGGING_FORMAT, datefmt=LOGGING_DATE_FORMAT, |
| 28 level=level) |
| 29 |
| 30 |
| 31 def LogCommandLine(): |
| 32 """Log the command line used to run this program.""" |
| 33 logging.debug(' '.join(sys.argv)) |
OLD | NEW |