From: W. Trevor King Date: Thu, 12 Aug 2010 15:12:29 +0000 (-0400) Subject: Add --debug option to bin/hooke and log CommandEngine.run_command() X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8fd6046cf6e14aef820e949a1c485e2a4957db10;p=hooke.git Add --debug option to bin/hooke and log CommandEngine.run_command() --- 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())