def __exit__(self, exec_type, exec_val, exec_tb): log = self._log if exec_type is None: # check callable if _settings.is_debug(): actname = log._actname kwargs = log._kwargs _check_callable(ActionLog, actname, **kwargs) context._childs.append(log) context._exit(context, log) return False
def ignore_exception_if_no_debug(f, raise_value = None): if _settings.is_debug(): return f() else: try: return f() except Exception: import logging import traceback import sys info = sys.exc_info() type = info[0] value = info[1] tb = traceback.format_exc(info[2]) logger = logging.getLogger(__name__) logger.error('%s, %s, %s', type, value, tb) return raise_value