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

This commit is contained in:
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

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: