From 501b5343082d2f49a914e6af603dd3f93ef9ebf9 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Mon, 22 Nov 2010 01:50:46 -0800 Subject: [PATCH] Add a new --debug-pids option. This makes the helpers.* log functions prepend getpid() to each line, so you can see which pid did what. --- helpers.py | 6 ++++-- redo.py | 3 +++ vars.py | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/helpers.py b/helpers.py index 9c2b784..17301da 100644 --- a/helpers.py +++ b/helpers.py @@ -35,8 +35,10 @@ def mkdirp(d, mode=None): def log_(s): sys.stdout.flush() - sys.stderr.write(s) - #sys.stderr.write('%d %s' % (os.getpid(), s)) + if vars.DEBUG_PIDS: + sys.stderr.write('%d %s' % (os.getpid(), s)) + else: + sys.stderr.write(s) sys.stderr.flush() diff --git a/redo.py b/redo.py index fc2f148..1507bb8 100755 --- a/redo.py +++ b/redo.py @@ -12,6 +12,7 @@ x,xtrace print commands as they are executed (variables expanded) k,keep-going keep going as long as possible even if some targets fail shuffle randomize the build order to find dependency bugs debug-locks print messages about file locking (useful for debugging) +debug-pids print process ids as part of log messages (useful for debugging) """ o = options.Options('redo', optspec) (opt, flags, extra) = o.parse(sys.argv[1:]) @@ -30,6 +31,8 @@ if opt.shuffle: os.environ['REDO_SHUFFLE'] = '1' if opt.debug_locks: os.environ['REDO_DEBUG_LOCKS'] = '1' +if opt.debug_pids: + os.environ['REDO_DEBUG_PIDS'] = '1' is_root = not os.environ.get('REDO', '') diff --git a/vars.py b/vars.py index 9b04c31..e3f32cf 100644 --- a/vars.py +++ b/vars.py @@ -6,6 +6,7 @@ TARGET = os.environ.get('REDO_TARGET', '') DEPTH = os.environ.get('REDO_DEPTH', '') DEBUG = atoi.atoi(os.environ.get('REDO_DEBUG', '')) DEBUG_LOCKS = os.environ.get('REDO_DEBUG_LOCKS', '') and 1 or 0 +DEBUG_PIDS = os.environ.get('REDO_DEBUG_PIDS', '') and 1 or 0 VERBOSE = os.environ.get('REDO_VERBOSE', '') and 1 or 0 XTRACE = os.environ.get('REDO_XTRACE', '') and 1 or 0 KEEP_GOING = os.environ.get('REDO_KEEP_GOING', '') and 1 or 0