From 8fd6046cf6e14aef820e949a1c485e2a4957db10 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 12 Aug 2010 11:12:29 -0400 Subject: [PATCH] Add --debug option to bin/hooke and log CommandEngine.run_command() --- hooke/config.py | 2 +- hooke/engine.py | 5 ++++- hooke/hooke.py | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hooke/config.py b/hooke/config.py index cba24d1..5948974 100644 --- a/hooke/config.py +++ b/hooke/config.py @@ -106,7 +106,7 @@ DEFAULT_SETTINGS = [ Setting('logger_hooke', 'qualname', 'hooke'), Setting('handler_hand1', help='Configure the default log handler, see\nhttp://docs.python.org/library/logging.html#configuration-file-format', wrap=False), Setting('handler_hand1', 'class', 'StreamHandler'), - Setting('handler_hand1', 'level', 'WARN'), #NOTSET'), + Setting('handler_hand1', 'level', 'WARN'), Setting('handler_hand1', 'formatter', 'form1'), Setting('handler_hand1', 'args', '(sys.stderr,)'), Setting('formatter_form1', help='Configure the default log formatter, see\nhttp://docs.python.org/library/logging.html#configuration-file-format', wrap=False), diff --git a/hooke/engine.py b/hooke/engine.py index b438129..5bc2f6e 100644 --- a/hooke/engine.py +++ b/hooke/engine.py @@ -72,7 +72,8 @@ class CommandEngine (object): 'engine closing, placed hooke instance in return queue') break assert isinstance(msg, CommandMessage), type(msg) - log.debug('engine running %s' % msg.command.name) + log.debug('engine running %s with %s' + % (msg.command.name, msg.arguments)) msg.command.run(hooke, ui_to_command_queue, command_to_ui_queue, **msg.arguments) @@ -86,4 +87,6 @@ class CommandEngine (object): communication queues, so make sure they will not need user interaction. """ + log.debug('engine running internal %s with %s' + % (command.name, arguments)) command.run(hooke, NullQueue(), NullQueue(), arguments) diff --git a/hooke/hooke.py b/hooke/hooke.py index a8079a9..b16a800 100644 --- a/hooke/hooke.py +++ b/hooke/hooke.py @@ -196,6 +196,9 @@ def main(): '--command-no-exit', dest='command_exit', action='store_false', default=True, help="Don't exit after running a script or commands.") + p.add_option( + '--debug', dest='debug', action='store_true', default=False, + help="Enable debug logging.") options,arguments = p.parse_args() if len(arguments) > 0: print >> sys.stderr, 'More than 0 arguments to %s: %s' \ @@ -209,6 +212,10 @@ def main(): if options.version == True: print version() sys.exit(0) + if options.debug == True: + hooke.config.set( + section='handler_hand1', option='level', value='NOTSET') + hooke.load_log() if options.script != None: with open(os.path.expanduser(options.script), 'r') as f: options.commands.extend(f.readlines()) -- 2.26.2