Skip to content
Snippets Groups Projects
Commit e54b2454 authored by patavirt's avatar patavirt
Browse files

usadelndsoc: fix with_log_level

parent b6105f21
No related branches found
No related tags found
No related merge requests found
# -*- coding:utf-8; eval: (blacken-mode) -*-
import logging
import contextlib
logger = logging.getLogger(__name__)
......@@ -36,15 +35,23 @@ def _init_logging():
logging.config.dictConfig(cfg)
@contextlib.contextmanager
def with_log_level(level):
old_level = int(logger.level)
logger.setLevel(level)
try:
yield
finally:
logger.setLevel(old_level)
import functools
def deco(func):
@functools.wraps(func)
def wrapper(*a, **kw):
old_level = int(logger.level)
logger.setLevel(level)
try:
return func(*a, **kw)
finally:
logger.setLevel(old_level)
return wrapper
return deco
_init_logging()
del _init_logging, logging, contextlib
del _init_logging, logging
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment