From 37266a7945f70730477a149b66bae46010e86e2c Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Thu, 30 Sep 2010 12:23:38 +0200 Subject: [PATCH] add 'logging' command --- weboob/tools/application/repl.py | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/weboob/tools/application/repl.py b/weboob/tools/application/repl.py index 7f9527e3..de5e46c5 100644 --- a/weboob/tools/application/repl.py +++ b/weboob/tools/application/repl.py @@ -596,6 +596,39 @@ class ReplApplication(Cmd, BaseApplication): return choices + def do_logging(self, line): + args = self.parseargs(line, 1, 0) + levels = (('debug', logging.DEBUG), + ('info', logging.INFO), + ('warning', logging.WARNING), + ('error', logging.ERROR), + ('quiet', logging.ERROR), + ('default', logging.WARNING) + ) + + if not args[0]: + current = None + for label, level in levels: + if logging.root.level == level: + current = label + break + print 'Current level: %s' % current + return + + levels = dict(levels) + try: + logging.root.setLevel(levels[args[0]]) + except KeyError: + print >>sys.stderr, 'Level "%s" does not exist.' % args[0] + print >>sys.stderr, 'Availables: %s' % ' '.join(levels.iterkeys()) + + def complete_logging(self, text, line, begidx, endidx): + levels = ('debug', 'info', 'warning', 'error', 'quiet', 'default') + args = line.split(' ') + if len(args) == 2: + return levels + return () + def do_condition(self, line): """ condition [EXPRESSION | off]