Skip to content

Commit f446b2f

Browse files
add another logging level activated with -LL
1 parent 343fddc commit f446b2f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bpython/curtsies.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,23 @@
2727
def main(args=None, locals_=None, banner=None):
2828
config, options, exec_args = bpargs.parse(args, (
2929
'curtsies options', None, [
30-
Option('--log', '-L', action='store_true',
30+
Option('--log', '-L', action='count',
3131
help=_("log debug messages to bpython.log")),
3232
Option('--type', '-t', action='store_true',
3333
help=_("enter lines of file as though interactively typed")),
3434
]))
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)
3541
if options.log:
3642
handler = logging.FileHandler(filename='bpython.log')
37-
logging.getLogger('curtsies').setLevel(logging.WARNING)
3843
logging.getLogger('curtsies').addHandler(handler)
3944
logging.getLogger('curtsies').propagate = False
40-
logging.getLogger('bpython').setLevel(logging.WARNING)
4145
logging.getLogger('bpython').addHandler(handler)
4246
logging.getLogger('bpython').propagate = False
43-
else:
44-
logging.getLogger('bpython').setLevel(logging.ERROR)
45-
logging.getLogger('curtsies').setLevel(logging.ERROR)
4647

4748
interp = None
4849
paste = None

0 commit comments

Comments
 (0)