| Index: commit_queue.py
|
| diff --git a/commit_queue.py b/commit_queue.py
|
| index 327bff448676f80ccba104ebe1d904fdae613405..bf3f789dae4b9414b2844875f5d803b74849ce0a 100755
|
| --- a/commit_queue.py
|
| +++ b/commit_queue.py
|
| @@ -15,7 +15,6 @@ import os
|
| import signal
|
| import sys
|
| import time
|
| -import traceback
|
|
|
| import find_depot_tools # pylint: disable=W0611
|
| import checkout
|
| @@ -127,6 +126,33 @@ def AlertOnUncleanCheckout():
|
| '$ gclient diff\n%s' % diff))
|
|
|
|
|
| +def SetupLogging(options):
|
| + """Configures the logging module."""
|
| + logging.getLogger().setLevel(logging.DEBUG)
|
| + if options.verbose:
|
| + level = logging.DEBUG
|
| + else:
|
| + level = logging.INFO
|
| + console_logging = logging.StreamHandler()
|
| + console_logging.setFormatter(logging.Formatter(
|
| + '%(asctime)s %(levelname)7s %(message)s'))
|
| + console_logging.setLevel(level)
|
| + logging.getLogger().addHandler(console_logging)
|
| +
|
| + log_directory = 'logs-' + options.project
|
| + if not os.path.exists(log_directory):
|
| + os.mkdir(log_directory)
|
| +
|
| + logging_rotating_file = logging.handlers.RotatingFileHandler(
|
| + filename=os.path.join(log_directory, 'commit_queue.log'),
|
| + maxBytes= 10*1024*1024,
|
| + backupCount=50)
|
| + logging_rotating_file.setLevel(logging.DEBUG)
|
| + logging_rotating_file.setFormatter(logging.Formatter(
|
| + '%(asctime)s %(levelname)-8s %(module)15s(%(lineno)4d): %(message)s'))
|
| + logging.getLogger().addHandler(logging_rotating_file)
|
| +
|
| +
|
| def main():
|
| parser = optparse.OptionParser(
|
| description=sys.modules['__main__'].__doc__)
|
| @@ -181,30 +207,7 @@ def main():
|
| parser.error('Need to pass a valid project to --project.\nOptions are: %s' %
|
| ', '.join(project_choices))
|
|
|
| - logging.getLogger().setLevel(logging.DEBUG)
|
| - if options.verbose:
|
| - level = logging.DEBUG
|
| - else:
|
| - level = logging.INFO
|
| - console_logging = logging.StreamHandler()
|
| - console_logging.setFormatter(logging.Formatter(
|
| - '%(asctime)s %(levelname)7s %(message)s'))
|
| - console_logging.setLevel(level)
|
| - logging.getLogger().addHandler(console_logging)
|
| -
|
| - log_directory = 'logs-' + options.project
|
| - if not os.path.exists(log_directory):
|
| - os.mkdir(log_directory)
|
| -
|
| - logging_rotating_file = logging.handlers.RotatingFileHandler(
|
| - filename=os.path.join(log_directory, 'commit_queue.log'),
|
| - maxBytes= 10*1024*1024,
|
| - backupCount=50)
|
| - logging_rotating_file.setLevel(logging.DEBUG)
|
| - logging_rotating_file.setFormatter(logging.Formatter(
|
| - '%(asctime)s %(levelname)-8s %(module)15s(%(lineno)4d): %(message)s'))
|
| - logging.getLogger().addHandler(logging_rotating_file)
|
| -
|
| + SetupLogging(options)
|
| try:
|
| work_dir = os.path.join(ROOT_DIR, 'workdir')
|
| # Use our specific subversion config.
|
| @@ -336,19 +339,18 @@ def main():
|
| sys.stdout.write('Running (please do not interrupt) \r')
|
| sys.stdout.flush()
|
| next_loop = time.time() + options.poll_interval
|
| + except: # Catch all fatal exit conditions.
|
| + logging.exception('CQ loop terminating')
|
| + raise
|
| finally:
|
| - print >> sys.stderr, 'Saving db... '
|
| + logging.warning('Saving db...')
|
| pc.save(db_path)
|
| pc.close()
|
| - print >> sys.stderr, 'Done! '
|
| + logging.warning('db save successful.')
|
| except KeyboardInterrupt as e:
|
| print 'Bye bye'
|
| # 23 is an arbitrary value to signal loop.sh that it must stop looping.
|
| return 23
|
| - except SystemExit as e:
|
| - traceback.print_exc()
|
| - print >> sys.stderr, ('Tried to exit: %s', e)
|
| - return e.code
|
| except errors.ConfigurationError as e:
|
| parser.error(str(e))
|
| return 1
|
|
|