7 class Error(wizard.Error):
8 """Base error class for all command errors"""
11 def makeLogger(options):
12 logger = logging.getLogger("main")
13 logger.setLevel(logging.INFO)
14 stdout = logging.StreamHandler(sys.stdout)
15 logger.addHandler(stdout)
19 if not options.debug: stdout.setLevel(logging.ERROR)
20 if options.debug: logger.setLevel(logging.DEBUG)
23 class NullLogHandler(logging.Handler):
24 """Log handler that doesn't do anything"""
25 def emit(self, record):
28 class WizardOptionParser(optparse.OptionParser):
29 """Configures some default user-level options"""
30 def __init__(self, *args, **kwargs):
31 optparse.OptionParser.__init__(self, *args, **kwargs)
32 self.add_option("-v", "--verbose", dest="verbose", action="store_true",
33 default=False, help="Turns on verbose output")
34 self.add_option("--debug", dest="debug", action="store_true",
35 default=False, help="Turns on debugging output")
36 def parse_all(self, argv, logger):
37 options, numeric_args = self.parse_args(argv)
38 return options, numeric_args, logger and logger or makeLogger(options)