If level is None, don't bother making the nullcontext.

master
voussoir 2021-10-25 12:28:22 -07:00
parent c3c22270ee
commit ba6cb79529
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 2 additions and 3 deletions

View File

@ -241,11 +241,10 @@ def main_decorator(subject, *, log_return_value=True, **kwargs):
def wrapper(main):
def wrapped(argv):
(argv, level) = get_level_by_argv(argv)
context = main_log_context(subject, level, **kwargs)
if isinstance(context, contextlib.nullcontext):
if level is None:
return main(argv)
context = main_log_context(subject, level, **kwargs)
with context:
status = main(argv)
if log_return_value: