|
27 | 27 | def main(args=None, locals_=None, banner=None): |
28 | 28 | config, options, exec_args = bpargs.parse(args, ( |
29 | 29 | 'curtsies options', None, [ |
30 | | - Option('--log', '-L', action='store_true', |
| 30 | + Option('--log', '-L', action='count', |
31 | 31 | help=_("log debug messages to bpython.log")), |
32 | 32 | Option('--type', '-t', action='store_true', |
33 | 33 | help=_("enter lines of file as though interactively typed")), |
34 | 34 | ])) |
| 35 | + if options.log is None: |
| 36 | + options.log = 0 |
| 37 | + logging_levels = [logging.ERROR, logging.INFO, logging.DEBUG] |
| 38 | + level = logging_levels[min(len(logging_levels), options.log)] |
| 39 | + logging.getLogger('curtsies').setLevel(level) |
| 40 | + logging.getLogger('bpython').setLevel(level) |
35 | 41 | if options.log: |
36 | 42 | handler = logging.FileHandler(filename='bpython.log') |
37 | | - logging.getLogger('curtsies').setLevel(logging.WARNING) |
38 | 43 | logging.getLogger('curtsies').addHandler(handler) |
39 | 44 | logging.getLogger('curtsies').propagate = False |
40 | | - logging.getLogger('bpython').setLevel(logging.WARNING) |
41 | 45 | logging.getLogger('bpython').addHandler(handler) |
42 | 46 | logging.getLogger('bpython').propagate = False |
43 | | - else: |
44 | | - logging.getLogger('bpython').setLevel(logging.ERROR) |
45 | | - logging.getLogger('curtsies').setLevel(logging.ERROR) |
46 | 47 |
|
47 | 48 | interp = None |
48 | 49 | paste = None |
|
0 commit comments